Ant*_*oro 3 vue.js vue-router nuxt.js vuejs3 vue-router4
我正在尝试使用 nuxt3 (“3.0.0-rc.3”)建立一个简单的动态链接,但无法访问动态 slug url。我关注了此页面,但它似乎对我不起作用: https ://nuxtjs.org/examples/routing/dynamic-pages
这是我的简单页面结构:
pages/
index.vue
category/
_id.vue
Run Code Online (Sandbox Code Playgroud)
当我尝试访问我的localhost:3000/category/test网站时,出现 404 错误页面,其中显示消息“找不到页面:/category/test”。
这是我的“index.vue”文件中的链接:
<NuxtLink to="/category/test">Test</NuxtLink>
Run Code Online (Sandbox Code Playgroud)
这是我的“_id.vue”文件的内容:
<template>
<div>
<h1>Project: {{ $route }}</h1>
</div>
</template>
<script>
export default {}
</script>
<style>
</style>
Run Code Online (Sandbox Code Playgroud)
在 Nuxt 3 中,动态路由的写法[id]如下_id:
pages/
index.vue
category/
[id].vue
Run Code Online (Sandbox Code Playgroud)
有关更多详细信息,请检查此https://v3.nuxtjs.org/guide/directory-struct/pages#dynamic-routes