// 监视属性
watch:{
//正常写法
isHot:{
immediate:true,//初始化时让handler调用一下
deep:true,//监视多级结构中所有属性的变化
// 不需要上面两项配置项时可以简写
handler(newValue,oldValue){
console.log(newValue,oldValue);
}
},
//简写形式
isHot(newValue,oldValue){
console.log(newValue,oldValue);
}
}
在Vue实例外的写法
vm.$watch('isHot',function(newValue,oldValue){
console.log(newValue,oldValue);
})