vue watch怎样同时监听两个值的变化并执行方法?
用computed定义一个changeData对象吧,然后再去watch changeDatacomputed: {changeData() {const { index, columName,columData} = thisreturn {index,columName,col...
·
用computed定义一个changeData对象吧,然后再去watch changeData
computed: {
changeData() {
const { index, columName,columData} = this
return {
index,
columName,
columData,
}
}
},
watch: {
changeData: {
handler: function (newval, oldval) {
this.index = newval.index;
this.columName = newval.columName;
this.columData = newval.columData;
let length = this.columName.length;
let end = 700/length-1; // 横坐标展示7类
let show = false;
if(length >7){
show = true;
}
this.buildChart(this.columLabel,this.columName,this.columData,show,end);
},
deep: true
}
}
更多推荐
已为社区贡献5条内容
所有评论(0)