<el-table-column label="Group" prop="group" align="center" :formatter="stateFormat">
<template slot-scope="scope">
<div v-if="newVersion">
<el-tag type="primary" size="mini"> {{scope.row.group|$_groupConstConfigFilter}} </el-tag>
</div>
<span v-if="!newVersion" v-html="stateFormat(scope.row.group)"></span>
</template>
</el-table-column>
重点在标红地方,上面是html代码。
下面js代码实现formatter
stateFormat(group) { for (let i = 0; i < this.groups.length; i++) { if (group == this.groups[i].code) { return this.groups[i].name; } } return group }