"Cannot read properties of undefined (reading 'matched')"

vue cli要根据路由生成菜单,于是将new Router赋值给一个常量,再将常量导出,但是会报错
 "Cannot read properties of undefined (reading 'matched')"
页面也渲染不出来。
具体代码如下

更改前代码↓

const routes = [

{

name: "layout",

path: '/',

component: () => import('@/layout'),

redirect: '/home',

children: [

{

path: '/home',

name: 'home',

component: home,

meta: { title: '首页' }

},

]

},

]

export default new Router({({

routes: routes

})

更改后代码↓

const routes = [

{

name: "layout",

path: '/',

component: () => import('@/layout'),

redirect: '/home',

children: [

{

path: '/home',

name: 'home',

component: home,

meta: { title: '首页' }

},

]

},

]

const router = new Router({

routes: routes

})

请问这是为什么?。。

以上是 "Cannot read properties of undefined (reading 'matched')" 的全部内容, 来源链接: utcz.com/p/936504.html

回到顶部