<view class="">{{filterDeviceStatus(item.deviceRunStatus) }}</view>
computed:{
filterDeviceStatus(){
return function(value){
let v = '';
for (let i = 0; i < this.dictData.length; i++){
// console.log('value',value);
// console.log('value',this.dictData[i]);
let item = this.dictData[i];
if (value == item.status) {
v = item.dictLabel;
break;
}
}
return v
}
}
},
数据字典
后端返回的数据字典处理
res.data.map(function(currentValue){
that.dictData.push({value:currentValue.dictValue,label:currentValue.dictLabel})
// console.log('currentValue',currentValue);
})
转载请注明:有爱前端 » filters过滤器中不能使用this改用computed