下拉菜單在表格中使用,如何獲取單條數據的id或者獲取其他參數,當時有點糾結了
主要是用到 command事件 和 command屬性
這樣操作一波
el-dropdown 里定義一個@command="handleCommand"
el-dropdown-item 里綁定 :command = " beforeHandleCommand(scope.$index, scoped.row, '設置') " (表格template slot-scoped="scope")
el-dropdown-item 里綁定 :command = " beforeHandleCommand(scope.$index, scoped.row, '打開') "
beforeHandleCommand(index, row , command){
return{ index, row, command }
}
handleCommand(command){
//可以相對應的進行操作
switch(command.command){
case " 設置 ":
console.log(command.command) //設置
break;
case "打開":
console.log(command.command) //打開
beak;
}
}
