Answer the question
In order to leave comments, you need to log in
How to properly organize VueJS dynamic search?
in App.vue
I have a watch that keeps track of this.$route.query
watch: {
'$route.query': {
handler: function(query_string) {
// здесь код
},
deep: true,
immediate: true
}
}
router_push(query_string) {
let query_object = Object.fromEntries(query_string.split("&").map((pair) => pair.split("=")))
for (let key in router.currentRoute.query) {
for (let key_inner in query_object) {
if (key_inner !== key) {
query_object[key] = router.currentRoute.query[key]
}
}
}
const result_query_string = Object.entries(query_object)
.map((pair) => pair.join("="))
.join("&");
router.push(`${router.currentRoute.path}?${result_query_string}`).catch(err => console.log(err))
},
Answer the question
In order to leave comments, you need to log in
throw everything away.
https://router.vuejs.org/ru/guide/essentials/navig... - pass object https://router.vuejs.org/ru/api/#%D1%81%D0%B2%D0 to location %B...
set watch on '$route.query' {name: '...', {query: {...}}}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question