I made a component like below in Vuejs.
But my goal is I want to get the value inside of filterdShoes of watch.
data():{
coor: [
{ "name": '',
"shoes": '' },
{ "name": '',
"shoes": '' }
]
},
computed {
filteredAny(){
return this.coor.filter(it=>['shoes','name'].includes(it));
},
filteredShoes(){
return this.coor.filter(it=>it === 'shoes');
},
filteredName(){
return this.coor.filter(it=>it === 'name');
}
}
watch {
filteredShoes(){
console.log('The shoes are changed');
}
}
So I tried like below.But it says val is undefined.
I hope that 'val' is defined as 'coor' of data.
How can I fix this code? Thank you so much for reading this.
watch {
filteredShoes(val){
for(let i=0; i < val.length; i+=1){}
}
}