LoginSignup
0
0

More than 1 year has passed since last update.

Nuxt.js 3 の動的ルーティングでハマったこと

Last updated at Posted at 2023-02-07

例えば /posts/1, /posts/2 のようにアクセスしたい場合
Nuxt.js 2では以下の書き方でした

pages/
--| about.vue
--| posts/
----| _id.vue

Nuxt.js 3では以下のように []で囲む必要があります

pages/
--| about.vue
--| posts/
----| [id].vue

[id].vue内でid値にアクセスする場合は以下で可能です(Vue.js 3のsetup使用時)

<script setup lang='ts'>

const route = useRoute()
const id = route.params.id

</script>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0