31
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Nuxt.jsでURLからパラメーターを取得する

Last updated at Posted at 2019-05-15

パスからパラメーターを取得する

localhost:3000/post/12345/ にアクセスした時に12345の部分を取得したい。

pages/
--| post/
-----| _id.vue
_id.vue
<template>
  <section>
    <p>{{ $route.params.id }}</p>
  </section>
</template>

参考:動的なルーティング

Getパラメーターを取得する

localhost:3000/post/?id=12345 にアクセスした時に12345の部分を取得したい。

pages/
--| post/
-----| index.vue
index.vue
<template>
  <section>
    <p>{{ $route.query.id }}</p>
  </section>
</template>
31
19
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
31
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?