vue+element下拉選項添加點擊事件可跳轉或觸發事件


1、附上代碼,想用直接復制方便 
 <el-dropdown @command="handleCommand">
          <img
            v-if="this.$store.state.deptId == 1"
            class="el-dropdown-link"
            src="../assets/20191211圖標/20191211圖標/系統設置.png"
            style="width:90px;height:50px"
          />
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item command="userGroup">用戶分組管理</el-dropdown-item>
            <el-dropdown-item command="userGroup2">PMS信息導入</el-dropdown-item>
            <el-dropdown-item command="userGroup3">歷史修改記錄</el-dropdown-item>
            <el-dropdown-item command="userGroup4">數據自動更新</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
2、
    handleCommand(cmditem) {
      if (!cmditem) {
        this.$message("菜單選項缺少command屬性");
        return;
      }
      switch (cmditem) {
        case "userGroup":
          this.userGroup();
          break;
        case "userGroup2":
          this.userGroup2();
          break;
        case "userGroup3":
          this.userGroup3();
          break;
        case "userGroup4":
          this.userGroup4();
          break;
      }
    },
 
3、
  userGroup() {
      this.$router.push("/dept_user");
    },
    userGroup2() {
      this.centerDialogVisible = true;
    },
    userGroup3() {
      this.$router.push("/history");
    },
    userGroup4() {
      this.updatas();
      this.centerDialogVisibled = true;
    },


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM