el-table中的由数据列与操作列组成,数据列可以正常的绑定,现在的问题是操作列的中的一些操作按钮会根据数据列中的某列内容来判断是否显示,不知如何编写?
<template>
<div>
<el-table :data="tableData" >
<el-table-column v-for="(value,index) in tableCol" :key="index"
:prop="value.prop"
:label="value.label"
:width="value.width">
</el-table-column>
<!--基础操作-->
<el-table-column label="操作">
<template slot-scope="scope">
<el-button
type="text"
v-for="(value,index) in operator"
@click="value.click(scope.row, value)"
:key="index">
{{ value.text }}
</el-button>
</template>
</el-table-column>
</el-table>
</div>
</template>
tableData的内容为:
[
{hao:'1',zt:'1'},
{hao:'1',zt:'2'},
{hao:'1',zt:'3'},
]
tableCol的内容为:[
{
prop: "hao",
label: "号码",
width: "160px",
align: "center",
fixed: false,
},
{
prop: "zt",
label: "状态",
width: "160px",
align: "center",
fixed: false,
},
]
operator: [{
text: "详情",
type:'info',
icon: "el-icon-setting",
click: (row, col, cellValue) => {
return this.xiaFa(row);
},
},
{
text: "编辑",
icon: "el-icon-edit",
click: (row, col, cellValue) => {
return this.editRow(row);
},
},
{
text: "删除",
icon: "el-icon-delete",
click: (row, col, cellValue) => {
return this.delRow(row);
},
},
],
问题:当一行的zt值不同时,opeartor中操作按钮显示与隐藏?难点在于每行zt值仅影响不行!