17
22

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.

vue-routerやnuxt.jsのqueryでの遷移で再レンダーが走らない時の対処法

Posted at

下記の様なリンクを作ったときに再レンダーしない時の対処法

<router-link :to="{path: hoge, query: {name: `${fuga}`}}">
  {{ fuga }}へ
</router-link>

vue-routerの場合

<router-view :key="$route.fullPath" />

とすると良いらしい。

nuxt.jsの場合

layoutディレクトリの<nuxt />に設定する

default.vue
<template>
  <nuxt :nuxt-child-key="$route.fullPath" />
</template>

nuxtで動的ページ扱いにすればいい話なんだけど、検索クエリでも再レンダーしたくて困ったけど解決できた。

17
22
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
17
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?