有时候,后端传回来的数据不能直接用,需要转一下,有些字典值,后端直接返回了key,
需要我们转成对应的value,这时候可以用官网给出的formatter函数
<el-table-column prop="sex" label="性别">
<template slot-scope="scope">
<span>{{sexFormat(scope.row.sex)}}</span>
</template>
</el-table-column>
sexFormat (val) {
let name = ''
this.sexList.forEach(item => {
if ( item.id === val ) {
name = item.name
}
})
return name
}
这样就可以在页面上展示出来想要的枚举值了。