Vue ,elementUI,dropdown組件中command方法添加額外參數的方法
我們在使用dropdown組件的時候,需要的參數可能很多,不僅僅是command一個參數。這就需要構造一個結構了。
<el-dropdown @command="handleCommand">
<el-dropdown-menu slot="dropdown">
<template v-for="item in items">
<el-dropdown-item v-for="it in item " :command="composeValue(it,scope.row)"/>
</template>
</el-dropdown-menu>
</el-dropdown>
方法部分的處理:
methods: {
handleCommand(command) {
console.log(command)
},
composeValue(item, row) {
return {
'button': item,
'row': row
}
}
作者:些許青絲
鏈接:https://www.jianshu.com/p/b86e79ca9382
來源:簡書
簡書著作權歸作者所有,任何形式的轉載都請聯系作者獲得授權並注明出處。