列表角色包含‘超级管理员’时删除按钮置灰
//this.tableData=[{createTime:"2021-08-10 16:17:18",roleList: [{roleId: "2071802768015679540", roleName: "测试角色"}, {roleId: "2062895985096130886", roleName: "超级管理员"}]}]
<el-table :data="tableData" style="width: 100%">
<el-table-column label="所属角色" min-width="160" show-overflow-tooltip>
<template slot-scope="scope">
<span v-for="(item, index) in scope.row.roleList" :key="index">{{
scope.row.roleList.length - 1 !== index ? item.roleName + ',' : item.roleName
}}</span>
</template>
</el-table-column>
<el-table-column label="操作" width="118" fixed="right">
<template slot-scope="scope">
//blue-text为蓝色字体样式,disabled-text为灰色字体样式
<el-button
type="text"
:class="scope.row.roleList.some(item => item.roleName =='超级管理员')?'disabled-text':'blue-text'"
:disabled="scope.row.roleList.some(item => item.roleName =='超级管理员')"
@click="handleDelete(scope.$index, scope.row)"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
效果图:
![](https://i-blog.csdnimg.cn/blog_migrate/979ff30ec3b79ba930215193b3c8025c.png)