在vue中组件如果想要监听vuex中新旧值的变化,可以采用
computed:{
listenList(){
return JSON.parse(JSON.stringify(this.store.listen)) //拷贝vuex里的数组
}
},
watch:{
listenList:{
deep:true,
handler(newVal,oldVal){
console.log(newVal,oldVal);
}
}
}
}
这样就可以拿到变化前后的新旧值