I have some computed properties with different values, may I ask anyway to organize my data?
computed: {
totalCoin() {
const state = this.$store.state.ApiState.totalCoin
let val
if (state === 0) {
val = 0
} else if (state === null) {
val = undefined
} else {
val = state
}
return val
},
totalGem() {
const state = this.$store.state.ApiState.totalGem
let val
if (state === 0) {
val = 0
} else if (state === null) {
val = undefined
} else {
val = state
}
return val
}
repeatedly...
}
Note: Every results value will return from VueX to a component by computed properties
getToken() {
return this.$store.state.userToken
}
Is there a better way of doing this to improve readability?