Solve the problem of error when passing variables in vue dynamic routing component

menuList background data return format

{
    // 统计分析
    path: '/statistics',
    name: 'Statistics',
    meta:{title: '数据统计'},
    component: 'views/statistics/Statistics'
}

component in routing

What is received is that  @/views/statistics/Statistics the page can be displayed normally.

If the parameters are dynamic, the following three types will report errors and the page will be blank.

 

let cop = `@/${item.component}`
// item.component = () => import(cop)
// item.component = resolve => require([cop], resolve)
// item.component = Promise.resolve().then(() => require(`@/${item.component}`))

 Is there any good way to solve this problem?

name is the component page address

item.component = (name) => () => import(`@/${name}.vue`)

Guess you like

Origin blog.csdn.net/qq_17189095/article/details/131807852