1、通过command方法直接传当前选中行的整个数据
html
<el-table>
<el-table-column label="操作" width="100">
<template slot-scope="scope">
// @command="command=>方法名(command,你想传的其它参数)"
<el-dropdown @command="(command)=>{handleCommand(command, scope.row)}"> // 主要这行代码
<el-button class="search-btn" size="mini" type="primary">
更多
<i class="el-icon-arrow-down el-icon--right"></i>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="snmp-configure"
>SNMP配置</el-dropdown-item>
<el-dropdown-item command="export_excel"
>导出</el-dropdown-item>
<el-dropdown-item command="deldte" >删除</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
js文章来源:https://www.toymoban.com/news/detail-561684.html
methods:{
handleCommand(command,row) {
//拿到当行数据和command进行判断
switch (command) {
case "snmp-configure":
this.dialogTitleSnmp = "SNMP配置";
this.dialogFormSNMP = true;
break;
case "export_excel":
this.exportExcel();
break;
case "deldte":
this.deleteSingleHandler(row.id);//拿到当行数据的id进行删除操作
}
},
}
效果:文章来源地址https://www.toymoban.com/news/detail-561684.html
到了这里,关于vue+element-ui Dropdown下拉菜单(获取某行数据)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!