table.vue table组件 ,重写组件 当状态列为0时显示禁用,为1时显示启用,并添加过滤器更改 el-tag的样式
<template>
<el-table :data="tableData" border element-loading-text="拼命加载中">
<el-table-column
v-for="(th, key) in tableKey"
:key="key"
:prop="th.prop"
:label="th.label"
:fixed="th.fixed"
:width="th.width"
:align="th.align"
show-overflow-tooltip="true"
>
<template slot-scope="scope">
<div v-if="th.label === '状态'">
<el-tag :type=" scope.row[th.prop] | statusFilter">{
{ scope.row[th.prop] === 1 ? '启用' : '禁用' }}</el-tag>
</div>
<div v-else>
<span>{
{ scope.row[th.prop] }}</span>
</div>
</template>
</el-table-column>
</el-table>
</template>
<script>
export default {
name: 'Table',
filters: {
statusFilter(status) {
const statusMap = {