Vue - elementUI 下拉菜单dropdown组件中command方法添加额外参数

在使用dropdown组件的时候,需要的参数可能很多,不仅仅是command一个参数。这就需要通过composeValue构造一个结构了。

<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>


//方法部分的处理
    handleCommand(command) {
      console.log(command)
    },
    composeValue(item, id) {
      return {
        button: item,
        id: id
      }
    }

打印结果

 

table中

      <el-table-column label="操作" width="250" fixed="right">
        <template slot-scope="scope">
          <el-button type="success" @click.stop="goPutin(scope.row)"
            >编辑投放列表</el-button
          >
          <el-dropdown
            @command="(command) => handleCommand(command, scope.row)"
          >
            <el-button type="primary"
              >更多菜单<i class="el-icon-arrow-down el-icon--right"></i
            ></el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item command="remake">备注</el-dropdown-item>
              <el-dropdown-item command="edit">编辑产品</el-dropdown-item>
              <el-dropdown-item command="changeSort">排序</el-dropdown-item>
              <el-dropdown-item command="remove">删除</el-dropdown-item>
              <el-dropdown-item command="overHz">{{
                scope.row.productCooperation == 1 ? "终止合作" : "恢复合作"
              }}</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </el-table-column>


<script>
    // 更多操作触发
    handleCommand(command, row) {
      switch (command) {
        case "remake":
          this.remake(row);
          break;
        case "edit":
          this.edit(row);
          break;
        case "changeSort":
          this.changeSort(row);
          break;
        case "remove":
          this.remove(row);
          break;
        case "overHz":
          this.overHz(row);
          break;
        default:
          break;
      }
    },


    edit(row) {
      this.$nextTick(() => {
        this.productId = row.productId;
        this.goodsType = "edit";
        this.$refs.goodsAdd.dialogVisible = true;
      });
    },
</script>

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值