vue学习笔记21 watch
作者:互联网
data:{
weather:25,
wear:'短袖'
}
实例属性写watch监控
构造器外部写法
app.$watch('xxx',function(){})
写在构造器里
watch:{
weather:function(nv,ov){
}
}
用computed实现 就不灵活了。例
computed:{
newWear:function(){
if(this.weather>=25){
return this.wear = 'T恤短袖'
}else if(this.weather<25 && this.weather>0){
return this.wear = '外套'
}else{
return this.wear = '棉衣'
}
}
},
标签:function,vue,return,21,watch,weather,wear,computed 来源: https://www.cnblogs.com/laohange/p/12828948.html