0👍
The issue is you’re using an implicit global x
where you should define it locally.
You should also define arr
outside the if
block.
getVipCustomersKeys(state) {
const arr = [] // define "arr" before the "if"
if (state.vipCustomers) {
for (let x in state.vipCustomers) { // define "x" locally
arr.push(x);
}
}
return arr;
},
Even better, just use Object.keys()
to return all the keys from state.vipCustomers
getVipCustomersKeys: ({ vipCustomers }) => Object.keys(vipCustomers ?? {})
- [Vuejs]-Can't access specific state property in Vuex store
- [Vuejs]-Change group of characters in a String
Source:stackexchange.com