// 之前一直不明白 watch 咋用 原来这么简单,就是告诉看你改变的值是啥就行了
data(){
return{
message:10,
borlen:true,
abc:1,
}
},
//就是比如data里有个borlen值 你要监听他
watch:{
borlen(){
console.log("改变值啦");
// return this.borlen;
},
}
// 直接监听就好了我去 那个borlen就是你要监听的值啊 不是命名方法啊
data(){
return{
message:10,
borlen:true,
abc:1,
data:{
data:100
}
}
},
//万一是个对象里的怎么监听呢 那就要用深度监听了
data:{//深度监听,可监听到对象、数组的变化
handler(val, oldVal){
console.log("深度监听");
},
deep:true //这个要开起来
}
//深度监听
data(){
return{
message:10,
borlen:true,
abc:1,
data:{
data:100
}
}
},
// 计算属性也很简单 比如上面的书 我要用到message和abc
computed:{
multiplication() {
return this.abc*this.message
}
},
//这个时候我们就可以用multiplication啦他会自动计算的啦
<div>{{multiplication}}</div>
//直接调用就行了啊
https://blog.csdn.net/ken_ding/article/details/79232807
map数组
var data = MoreProwerDel.map(function (MoreProwerDel) { return MoreProwerDel.Id; });
// ba MoreProwerDel的数据里的值 直接拿出来