代码如下:
HTML代码:
<el-table-column width="80px" align="center" :label="$t('deviceInfoObj.status')" v-bind:width="160"> <template slot-scope="scope"> <span v-html="statusFormatter(scope,scope.row.status)"></span> </template> </el-table-column>
方法中第一个参数为对象,第二个参数为对象属性.
JS代码:
statusFormatter(scope,value) { if(value == 1) { return "启用"; } if(value == 2) { return "禁用"; } return "未知"; },亲测有效!