0👍
I think you can just pass the team number as parameter like this :
teamName: (state) => (teamNumber) => state.teamData[teamNumber].name,
teamAcronym: (state) => (teamNumber) => state.teamData[teamNumber].acronym,
Of course, this might need some check to see if the team exists like :
teamName: (state) => (teamNumber) => state.teamData[teamNumber] ? state.teamData[teamNumber].name : ""
Looking to do a loop that will map over the length of the array and set the value that way
I don’t know if this is what you want but you can return all names from your store using the js
map function
Example
teamNames: (state) => state.teamData.map(team => team.name)
- [Vuejs]-Pass value from vuejs view once and use common for all controllers in laravel?
- [Vuejs]-Adding vue.js to attribute src
Source:stackexchange.com