在行里面添加slot插槽,写需要翻译字典的判断。
// el-table-column
<el-table-column
sortable
prop="questionType"
label="问题类型"
width="300"
>
<template slot-scope="scope">
<span>
{{
showDictValue(scope.row.questionType, userStatusDict || []) ||
scope.row.questionType
}}
</span>
</template>
</el-table-column>
//js
data(){
userStatusDict:[{
value:"01",
content:"上班"
},{
value:"02",
content:"睡觉"
}]
}
methods:{
/**
* 动态表格字典翻译
*/
showDictValue(val,dictArr){
if(val!=""){
return dictArr.filter(item=>item.value==val)[0].content;
}
}
}