美文网首页
element-ui Dropdown 传多个参数

element-ui Dropdown 传多个参数

作者: lovelydong | 来源:发表于2021-03-18 15:11 被阅读0次

    使用Dropdown 下拉菜单操作需要传入id

    <el-dropdown
     type="primary" 
      size="mini" 
     @command="handleCommand">
      操作
      <el-dropdown-menu slot="dropdown">
          <el-dropdown-item :command="beforeHandleCommand('a',id)">编辑</el-dropdown-item>
          <el-dropdown-item :command="beforeHandleCommand('b',id)">删除</el-dropdown-item>
       </el-dropdown-menu>
    </el-dropdown>
    
    beforeHandleCommand(item,id){
        return {
            'command': item,
            'id': id
      }
    },
    handleCommand(command){
        switch (command.command) {
            case "a":
              this.edit(command.id)
              break;
            case "b":
                this.del(command.id)
              break;
        }
    }
    
    

    相关文章

      网友评论

          本文标题:element-ui Dropdown 传多个参数

          本文链接:https://www.haomeiwen.com/subject/unzucltx.html