Recently, I have been working with vue-cli and vuex to implement a specific functionality. Here is the code snippet that showcases my current progress:
methods: {
filtered() {
let vol = this.$store.state.data[1].data.filter(i => i.type === 'vol')[0].measure || 0;
let weight = this.$store.state.data[1].data.filter(i => i.type === 'weight')[0].measure || 0;
}
}
In my data, there exists a 'vol' type but no 'weight' type, hence I want the variable weight
to be set as 0
.
However, I encountered an error stating
Cannot read property 'measure' of undefined
.
If anyone has any suggestions or solutions to this issue, please feel free to share. Thank you in advance!