1. Table表格從後臺接收數據並個性化展示
方法一:添加格式化函數
<el-table-column prop="status" label="流程狀態" min-width="70" :formatter="stateFormat">
,:formatter="stateFormat"
然後寫函數方法
stateFormat(row, column) {
if (row.status === 0) {
return '正常'
} else if (row.status === 1) {
return '暫停'
}
},
方法二:插槽
<el-table-column prop="status" label="流程狀態" min-width="70">
<template slot-scope="scope">
<span v-if="scope.row.status=='0'">正常</span>
<span v-if="scope.row.status=='1'" style="color:red;">暫停</span>
<span v-if="scope.row.status=='2'">終止</span>
</template>
</el-table-column>
效果: