选项:deep(监听单个值)
为了发现对象内部值的变化,可以在选项参数中指定 deep: true 。注意监听数组的变动不需要这么做。
选项:immediate (监听数组内部某个值)
在选项参数中指定 immediate: true 将立即以表达式的当前值触发回调:
data() {
return {
changevalue: this.listValue,
changetitle: this.listTitle,
changeYear: this.dataYear,
};
},
props: {
listValue: {
type: String,
default: ""
},
listTitle: {
type: String,
default: ""
},
dataYear: {
default: ""
},
},
components: {
},
watch: {
listValue: {
handler(newVal) {
this.changevalue = newVal;
setTimeout(() => {
this.initStyle(this.typeYearbooks, this.listValue);
}, 100);
},
deep: true,
immediate: true
},
listTitle: {
handler(newTitle) {
this.changetitle = newTitle;
setTimeout(() => {
this.initStyle(this.typeYearbooks, this.listValue);
}, 100);
},
deep: true,
immediate: true
},
dataYear: {
handler(newValue) {
this.changeYear = newValue;
setTimeout(() => {
this.initStyle(this.typeYearbooks, this.listValue);
// console.log(this.$refs.fromDomNoke);
}, 100);
},
deep: true,
immediate: true
},
dialogChartVisible(value) {
if (!value) {
this.dialogChange = value;
this.testChartsList = {};
}
}
},
网友评论