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;
}
},