场景
在el-table表格中,从后台获取到的数据是0、1、2等数字,前端在进行展示的时候,需要把数字转换成相应的字符串,在表格中进行展示
实现
<el-table-column
label="任务来源"
align="center"
:show-overflow-tooltip="true"
>
<template slot-scope="scope">
{{ getSrc(scope.row.mission_src) }}
</template>
</el-table-column>
methods: {
getSrc(mission_src) {
if (mission_src === 0) {
return '本地上传'
}else if (mission_src === 1) {
return '本地任务'
}else {
return '上级任务'
}
},
}