0👍
It mean this.query.hotels
is undefined. So add if condition like below
removeHotel(index) {
console.log(index);
if(this.query.hotels && this.query.hotels.length > 0) {
this.query.hotels.splice(index, 1);
}
//this.priceList = {};
},
0👍
You’ve expected this.query.hotels
to be an array but you didn’t define it as one at the time the function was called.
You can test if a variable is an Array by using the static .isArray
method
function removeHotel(index) {
if(Array.isArray(this.query.hotels) && this.query.hotels.length > 0) {
this.query.hotels.splice(index, 1);
}
}
- [Vuejs]-How to display an image in vuejs/vuetify whose path is in json fake server?
- [Vuejs]-Vue router react on parent component using a modal
Source:stackexchange.com