activeMetricName,在父页面,是个计算属性,作为props传到子页面,子页面还可以修改它。
这个报错,计算属性默认只有 getter ,双向数据绑定的时候,修改了它的值,不过在需要时你也可以提供一个 setter :
改之前:
activeMetricName () {
let metric = ''
if (this.c_itemAlarmInfo && this.active_index) {
metric = this.c_itemAlarmInfo[this.active_index].metricName
} else {
metric = COUNT
}
return metric
},
改之后:
activeMetricName: {
get () {
let metric = ''
if (this.c_itemAlarmInfo && this.active_index) {
metric = this.c_itemAlarmInfo[this.active_index].metricName
} else {
metric = COUNT
}
return metric
},
set (val) {
this.$emit('update:value', val)
}
},