Nuxt watchQuery()

Creator
Creator
Seonglae ChoSeonglae Cho
Created
Created
2021 Feb 25 13:50
Editor
Edited
Edited
2021 Apr 13 5:46
Refs
Refs

get query

  • Type: Boolean or Array or Function (default: [])
 
 
  • bool - allow all or not
  • array - allow specific querycod
  • function - refine query
 
watchQuery(newQuery, oldQuery) { // Only execute component methods if the old query string contained `bar` // and the new query string contains `foo` return newQuery.foo && oldQuery.bar }
 
 
 
 
The new fetch hook introduced in 2.12 is not affected by watchQuery
How to watch on Route changes with Nuxt and asyncData
First thing, context.route or it's alias this.$route is immutable object and should not be assigned a value. Instead, we should use this.$router and it's methods for programmatic navigation or and . As I understand, you need to render the same route, but trigger asyncData hook in order to update component's data.
How to watch on Route changes with Nuxt and asyncData

Recommendations