1:配置JSON数据
2:axios调取到数据使用forEach双重循环出二级菜单
3:一级二级循环
arr.forEach
循环第一级菜单
res.children
循环第二季菜单
this.$router.addRoute('home',{}
动态添加路由
component: () =>
import(`@/views/${red.path.substring(0,1).toUpperCase()+red.path.substring(1)}View.vue`),
跳转子路由的路径,因为路由是驼峰命名,但是返回的path是小写,
使用substring(0,1).toUpperCase()把首字母转成大写和我的路由命名匹配
-
:router="true 使用 vue-router 的模式,启用该模式会在激活导航时以 index 作为 path 进行路由跳转
-
:default-active='pagepath'表示一进入页面就默认激活'/home/users'导航菜单
-
default-active不能直接写死值路径要用变量代替 使用监听器 监听路由解决
- unique-opened 是否只保持一个子菜单的展开 boolean 默认是false