当前位置 博文首页 > hibiscusxin的博客:el-dropdown 的 command传递多个参数
<el-dropdown @command="changeState">
<el-dropdown-menu slot="dropdown">
<el-dropdown-item v-if="scope.row.isFrozen === 1" :command="commandValue('frozen', scope.row)">冻结</el-dropdown-item>
<el-dropdown-item v-if="scope.row.isFrozen === 0" :command="commandValue('unFrozen', scope.row)">解冻</el-dropdown-item>
<el-dropdown-item :command="commandValue('delete', scope.row)">删除</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
// 解析参数
commandValue(type, command) {
return {
'type': type,
'command': command
}
},
// 更改账号状态
changeState(item) {
const { type, command } = item
if (type === 'frozen') {
User.frozenAccount({ userId: command.userId }).then(res => {
if (res.success) {
this.getList()
}
})
} else if (type === 'unFrozen') {
User.unfrozenAccount({ userId: command.userId }).then(res => {
if (res.success) {
this.getList()
}
})
} else if (type === 'delete') {
console.log('delete')
}
}
cs