0👍
As said Chris, if I’m already on the route search-movies
, I am not doing a new request, so I can’t update the result.
My easier solution is to add this.$router.go(0);
on the submit()
function.
...
methods: {
submit() {
this.$router.replace({ name: "search-movies", query: { q: this.query } });
this.$router.go(0);
}
}
0👍
You can try to add a watcher on your $route.query
and refetch the search anytime the query changes:
methods: {
searchMovies(query) {
MOTService.searchMovies(query)
//...
});
}
},
created() {
this.searchMovies(this.$route.query);
},
watch: {
'$route.query'(value) {
this.searchMovies(value)
}
}
Source:stackexchange.com