Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vue.js change query location NavigationDuplicated

currently have query param id=2&p=3 want to change this with vue-router tried :

this.$router.push({query:{id:'2',p:'4'}});

but throws NavigationDuplicated

weird ..

how to change just the query, to trigger watch.

like image 754
user1983281 Avatar asked Oct 23 '25 16:10

user1983281


1 Answers

The error will be thrown only if your params the same, so you could just check your params before push or replace. Also, you could use async/await or then/catch with there methods, here is an example:

try {
  if (/* id or p have been changed in this.$route.query */) {
    await this.$router.push({query:{id:'2',p:'4'}});
  }

} catch (err) {
...
}
like image 86
dimacpp Avatar answered Oct 25 '25 11:10

dimacpp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!