watch和computed各自处理的数据关系场景不同
1.watch擅长处理的场景:一个数据影响多个数据
2.computed擅长处理的场景:一个数据受多个数据影响
watch: {
option1: {
handler(newVal, oldVal) {
if (this.tgshowdataList.length > 0) {
var myChart1 = echarts.init(document.getElementById('indexc2'));
if (myChart1) {
if (newVal) {
myChart1.setOption(newVal);
} else {
myChart1.setOption(oldVal);
}
}
}
},
immediate: true,
deep: true
}
}
computed: {
evidenceuploadList() {
return this.$refs.evidenceupload ? this.$refs.evidenceupload.fileList : [];
},
evidenceUploadUrl() {
return this.base.obj.onlinedomainUrl + '/legalcase/evidence/uploadFile';
},
}
网友评论