多状态映射

0 阅读1分钟
<el-table-column label="状态">
    <template slot-scope="scope">
      <el-tag :type="statusColor[scope.row.type]">{{ statusType[scope.row.type] || ''}}</el-tag>
    </template>
</el-table-column>

data() {
    retutn {
        statusType: {
            1: '缺货',
            2: '入位',
            3: '撤销'
        },
        statusColor: {
            0: '',
            1: 'danger',
            2: 'success',
            3: 'info'
        }
    }
}