【发布时间】:2021-12-01 23:37:34
【问题描述】:
在我的 nuxt 项目中,我的 pages 文件夹中有以下结构:
index.vue
tools
index.vue
_id.vue
page-not-found.vue
在我的 nuxt 配置中,我在路由器部分有这个:
router: {
extendRoutes(routes, resolve) {
routes.push(
{
name: '404',
path: '*',
component: resolve(__dirname, 'pages/page-not-found.vue')
},
)
},
}
当我登陆我的页面文件夹以外的 url 时,我显示了 url 和我的 404 组件(例如:my-domaine/other-path 显示 404 内容)。所以我想要的是我的路线tools-id 我想获取数据取决于参数id,如果有数据,我会显示带有详细信息的页面,但如果我没有数据,我希望有与我相同的行为404路;比如,在我的网址中,我有 my-domaine/tools/parameter_value,但我的网页显示 404 内容。
【问题讨论】: