vue 动态监听父级传过来的数据,如果父级传过来的数据有变,就调用方法(你想调用的),$nextTick要加上不然会因没加载完毕而报错,还有一点handler这里使用普通函数就行,箭头函数会导致this不知道指向谁
props:{
cId:Number
},
watch:{
cId:{
handler:function(val,oldval){
if(val!=oldval){
this.$nextTick(()=>{
this.getProductList()
})
}
},
immediate:true,//关键
deep:true
},
},