关于前端:nuxt3-自定义路由

2次阅读

共计 312 个字符,预计需要花费 1 分钟才能阅读完成。

根目录下创立 app/router.options.js 文件

router.options.js 如下

const customRoutes = [
  {
    name: 'home',
    path: '/',
    component: ()=> import('../pages/Home.vue')
  },
  {
    name: 'about',
    path: '/about1',
    component: ()=> import('../pages/About.vue')
  },
]
export default {routes:(_routes)=>[
    ..._routes,
    ...customRoutes
  ]
}

_routes 是零碎自带的,解构放入数组即可,customRoutes 可自定义编辑你的路由

正文完
 0