下拉handledropdown

el-dropdown

<el-dropdown trigger="click" @command="handleCommand" >
            <span class="el-dropdown-link" style="width: 65px;">
              <el-button type="text">{
    
    {
    
     lable }}</el-button>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item
                :command="item"
                :key="item"
                v-for="item in list"
                >{
    
    {
    
     item }}</el-dropdown-item
              >
            </el-dropdown-menu>
          </el-dropdown>

---------------------------------------------------------------------------------------------------------
 handleCommand(command) {
    
    
      console.log(command);
      this.lable = command;
      this.show = true;
    },          
  <span>
              <el-dropdown trigger="click" @command="handleDropdown">
                <i class="el-icon-plus"></i>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item command="folder">
                    <i class="iconfont icon-yewubao" style="color: #5c8fef"></i
                    >业务包
                  </el-dropdown-item>
                  <el-dropdown-item command="group">
                    <i
                      class="iconfont icon-tianjiafenzu"
                      style="color: #5c8fef"
                    ></i
                    >分组
                  </el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
            </span>
       ------------------------------------------------------------------------------------------------------------------
            //下拉菜单选项
    async handleDropdown(command) {
    
    
      console.log(command);
      if (command.data) {
    
    
        //解构
        var {
    
     data, command } = command;
        //分组下面的添加
        if (command == 0) {
    
    
          this.createFrom.type = 0;
          this.createFrom.name = "业务包";
          this.createFrom.parentId = data.id;
          await create(this.createFrom);

          this.getList();
        } else {
    
    
          this.createFrom.type = 1;
          this.createFrom.name = "分组";
          this.createFrom.parentId = data.id;
          await create(this.createFrom);
          this.getList();
        }
        //我的数据下面的添加(父节点是根节点)
      } else {
    
    
        //如果是文件夹 type=0,如果是分组默认为1
        if (command == "folder") {
    
    
          this.createFrom.type = 0;
          this.createFrom.parentId = 0;
          this.createFrom.name = "业务包";
          await create(this.createFrom);
          this.getList();
        } else {
    
    
          this.createFrom.type = 1;
          this.createFrom.parentId = 0;
          this.createFrom.name = "分组";
          await create(this.createFrom);
          this.getList();
        }
      }
    },

猜你喜欢

转载自blog.csdn.net/Ybittersweet/article/details/126763850