Vue 동적 라우팅 구성 요소에서 변수를 전달할 때 발생하는 오류 문제 해결

menuList 배경 데이터 반환 형식

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

라우팅의 구성요소

수신된 내용은  @/views/statistics/Statistics 페이지가 정상적으로 표시될 수 있다는 것입니다.

매개변수가 동적이면 다음 세 가지 유형이 오류를 보고하고 페이지가 비어 있게 됩니다.

 

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

 이 문제를 해결할 좋은 방법이 있나요?

이름은 구성 요소 페이지 주소입니다.

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

추천

출처blog.csdn.net/qq_17189095/article/details/131807852