1.创建表格
<el-table
ref="multipleTable"
:data="tableData"
border
>
<el-table-column fixed type="selection" align="center"></el-table-column>
<div v-for="(item,index) in columns" :key="index">
<el-table-column
:prop="item.prop"
:label="item.label"
:formatter="item.formatter"
align="center"
show-overflow-tooltip
></el-table-column>
</div>
</el-table>
2.创建表头+事件
文章来源地址https://www.toymoban.com/news/detail-583890.html
columns: [
{
prop: "index",
label: "序号",
formatter: (row, column, cellValue, index) => {
return <span οnclick={that.aa.bind(null, row)}>{index + 1}</span>;
}
},
{
prop: "userName",
label: "姓名"
},
{
prop: "roleName",
label: "角色名称"
},
{
prop: "topManagerUserVo",
label: "上级主管",
formatter: (row, column) => {
if (row.topManagerUserVo) {
return row.topManagerUserVo.roleName;
} else {
return "";
}
}
},
{
prop: "accountStatus",
label: "帐号状态",
formatter: (row, column) => {
if (row.accountStatus == 0) {
return "禁用";
}
if (row.accountStatus == 1) {
return "启用";
}
if (row.accountStatus == 2) {
return "已过期";
}
}
},
],
文章来源:https://www.toymoban.com/news/detail-583890.html
到了这里,关于element ui table某个单元格添加点击事件的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!