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;
    },
posted @ 2019-12-12 10:32  看到我的div了吗?  阅读(4051)  评论(0编辑  收藏  举报