正常写法:
watch:{
   isHot:{
      immediate:true, //初始化时让handler调用一下
      deep:true,//深度监视
      handler(newValue,oldValue){
         console.log('isHot被修改了',newValue,oldValue)
      }
   },
}
简写:
watch:{
   isHot(newValue,oldValue){
      console.log('isHot被修改了',newValue,oldValue,this)
   }
}
注意:只有在不配置其他属性的情况下才能用简写,比如:immediate和deep都不用,默认只监听深度:一级对象
                
                
                
发表评论 取消回复