elementUI中el-dropdown的command实现传递多个参数

<el-dropdown @command="handleCommand">

<span class="el-dropdown-link">

{{ dropdownName }}

<i class="el-icon-arrow-down el-icon--right"></i>

</span>

<el-dropdown-menu slot="dropdown">

<div v-for="item in matchList">

<el-dropdown-item :command="beforeHandleCommand(item.id,item.name)"> {{ item.name }}</el-dropdown-item>

</div>

</el-dropdown-menu>

</el-dropdown>

<script>

export default {

data() {

return {

tableData: [{

pk_id: 1,

mname: '中国机设',

mtype: '计算机',

date: '2016-05-02',

name: '燕山大学',

}, {

pk_id: 2,

mname: '蓝桥杯',

mtype: '计算机',

date: '2016-05-02',

name: '河北大学',

}],

dropdownName: "下拉菜单",

matchList: [{

id: 1,

name: "燕山大学"

}, {

id: 2,

name: "河北大学"

}, ],

}

},

methods: {

handleCommand(command) {

console.log(command);

this.dropdownName=command.command;

this.$message("id:"+command.index);

},

beforeHandleCommand(index, command) { //index我这里是遍历的角标,即你需要传递的额外参数

return {

'index': index,

'command': command

}

},

}

}

</script>

相关推荐
devincob1 天前
js原生、vue导出、react导出、axios ( post请求方式)跨平台导出下载四种方式的demo
javascript·vue.js·react.js
编程社区管理员1 天前
React 发送短信验证码和验证码校验功能组件
前端·javascript·react.js
全马必破三1 天前
React“组件即函数”
前端·javascript·react.js
三思而后行,慎承诺1 天前
React 底层原理
前端·react.js·前端框架
座山雕~1 天前
html 和css基础常用的标签和样式
前端·css·html
灰小猿1 天前
Spring前后端分离项目时间格式转换问题全局配置解决
java·前端·后端·spring·spring cloud
im_AMBER1 天前
React 16
前端·笔记·学习·react.js·前端框架
02苏_1 天前
ES6模板字符串
前端·ecmascript·es6
excel1 天前
⚙️ 一次性警告机制的实现:warnOnce 源码深度解析
前端
excel1 天前
Vue SFC 样式编译核心机制详解:compileStyle 与 PostCSS 管线设计
前端