我正在嘗試使用 nuxt3 ("3.0.0-rc.3") 建立一個簡單的動態鏈接,但我無法訪問動態 slug url。我關注了這個頁面,但它似乎對我不起作用: https ://nuxtjs.org/examples/routing/dynamic-pages
這是我的簡單頁面結構:
pages/
index.vue
category/
_id.vue
當我嘗試訪問我localhost:3000/category/test的 404 錯誤頁面時,顯示訊息“找不到頁面:/category/test”。
這是我的“index.vue”檔案中的鏈接:
<NuxtLink to="/category/test">Test</NuxtLink>
這是我的“_id.vue”檔案的內容:
<template>
<div>
<h1>Project: {{ $route }}</h1>
</div>
</template>
<script>
export default {}
</script>
<style>
</style>
uj5u.com熱心網友回復:
在 Nuxt 3 中,動態路由的寫法[id]如下_id:
pages/
index.vue
category/
[id].vue
有關更多詳細資訊,請查看此https://v3.nuxtjs.org/guide/directory-structure/pages#dynamic-routes
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/479359.html
標籤:Vue.js nuxt.js Vue路由器 Vuejs3 nuxtjs3
上一篇:從urlVueJs獲取查詢值
