vue+element下拉菜单添加事件
作者:互联网
<el-dropdown @command="handleCommand" v-if="this.$store.state.deptId == 1">
<img class="el-dropdown-link" src="../assets/20191207图标/20191207图标/首页.png" />
<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-menu>
</el-dropdown>
userGroup() {
this.$router.push("/dept_user");
},
userGroup2() {
alert(2);
},
userGroup3() {
alert(3);
},
handleCommand(cmditem) {
if (!cmditem) {
console.log("test");
this.$message("菜单选项缺少command属性");
return;
}
switch (cmditem) {
case "userGroup":
this.userGroup();
break;
case "userGroup2":
this.userGroup2();
break;
case "userGroup3":
this.userGroup3();
break;
}
},
标签:case,userGroup2,userGroup3,element,break,vue,userGroup,cmditem,下拉菜单 来源: https://www.cnblogs.com/web-shu/p/12014856.html