iview / iview/iview-admin

如何动态增减左侧菜单?

Open
#557 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Vue
Stars
16.3k
Forks
4.7k
PR merge metrics
No merged PRs in 30d

Description

采用如下方法动态添加菜单,可以显示,但是标签选项卡出不来,控制台报错
methods: {
loadMenu() {
for(var idx in this.$router.options.routes){
console.log(this.$router.options.routes[idx]);
}
this.$router.options.routes[7].children.push( {
path: 'hello_add',
icon: 'compose',
name: 'hello_add',
title: '动态添加Hello测试',
component: resolve => { require(['@/yttest/modules/simpletest/hello/hello_add.vue'], resolve); }
});
this.$router.addRoutes(this.$router.options.routes);
this.$store.commit('updateMenulist');
}
},

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the loadMenu method shown in the issue, especially the route mutation, addRoutes call, and updateMenulist commit. Reproduce the console error and trace the existing router, menu, and tab handling; done means a dynamically added route displays its corresponding menu entry and tab without errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.