【ElementUI】el-dropdown 下拉菜单

表格中下拉展示

【ElementUI】el-dropdown 下拉菜单_第1张图片

文档中的click事件是针对按钮触发事件的,不能用。最后我选择visible-change。

 【ElementUI】el-dropdown 下拉菜单_第2张图片

@visible-change 下拉框显示隐藏

原本是想在表格的每一项scope.row中添加product_list。最后因为product_list是每一行动态获取的,所以只能在下拉框显示的时候去调接口获取值。


  
    
  
async changeDrop(e,row) {
  if (e) {

    this.product_list = [
      { name:'牙刷',id:1 },
      { name:'牙膏',id:1 }
    ];

    // 接口获取
    const res = await getProduct({
       Id: row.id,
    });
    this.product_list = res.data;
  }
},

 更多操作

表格操作太多可以使用一个更多操作。

【ElementUI】el-dropdown 下拉菜单_第3张图片


  
    更多
  
  
    操作一
    操作二
  
// 更多
handleCommand(command, row) {
  switch (command) {
    case "handleOne":
      this.handleOne(row);
      break;
    case "handleTwo":
      this.handleTwo(row);
      break;
    default:
      break;
  }
},

你可能感兴趣的:(#,Element,elementui,vue.js,前端)