vue動的ルーティングコンポーネントで変数を渡すときにエラーが発生する問題を解決する

menuList バックグラウンド データの戻り形式

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

ルーティングのコンポーネント

受信した内容は、 @/views/statistics/Statistics ページが正常に表示できるというものです。

パラメータが動的である場合、次の 3 つのタイプはエラーを報告し、ページは空白になります。

 

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

 この問題を解決する良い方法はありますか?

name はコンポーネントページのアドレスです

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

おすすめ

転載: blog.csdn.net/qq_17189095/article/details/131807852