There seems to be a warning that I've encountered:
[Vue warn]: Error in render: "TypeError: Cannot read properties of undefined (reading 'nestedArray')"
How can I resolve this issue? Here is my beforeCreate function:
beforeCreate() {
this.$store.dispatch("loadCities").then((response) => {
this.cities = response;
this.sortingCities=this.cities.slice(0).sort(function(a,b) {
return a.row - b.row || a.col-b.col;
})
this.sortingCities.map(item => {
if (!this.nestedArray[item.row]) {
this.nestedArray[item.row] = [];
}
this.nestedArray[item.row][item.col] = item;
});
});
Here is my data property:
data() {
return {
cities: [],
selectedCity: null,
sortingCities:[],
nestedArray:[],
};
},
I am utilizing this property as follows:
<img :src="require(`../images/${this.nestedArray?.[row]?.[col].imageId}.png`)" alt="">