Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue动态加载路由后台获取菜单数据拼装成路由格式无法加载模块 #101

Open
yangzilong-java opened this issue Aug 13, 2020 · 0 comments

Comments

@yangzilong-java
Copy link

vue动态加载路由,后台获取菜单数据在component中路径拼接就找不模块,写死成一个字符串就可以。

`/**

  • 后台查询的菜单数据拼装成路由格式的数据
  • @param routes
  • @param data
    */
    export function generaMenu(routes, data) {
    data.forEach(item => {
    const url = '@/views/system/User'
    const menu = {
    path: item.path === '#' ? item.name : item.path,
    // 这样不行
    // component: item.path === '#' ? Layout : () => import(url),
    // 而下面这样就可以
    component: item.path === '#' ? Layout : () => import('@/views/system/User'),
    name: item.name,
    meta: item.meta,
    children: []
    }
    if (item.children !== null) {
    generaMenu(menu.children, item.children)
    }
    routes.push(menu)
    })
    }`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant