Vue-router: Push query or params cannot change the URL

Created on 25 Aug 2017  路  6Comments  路  Source: vuejs/vue-router

About push query:

  1. The current URL is "/foo?a=1"
  2. This.$router.push({path: '/foo', query: { a: 2}});
  3. The data will be changed in the "beforeRouteUpdate", but the URL does not change. (The proper URL should be "/foo?a=2", but it is still "/foo?a=1")

Replace params in nested router

  1. In the nested router: (The current URL is '/foo/:a/b/:c')
{
      path:'/foo/:a',
      name: 'foo',
      component: foo,
      children:[
          {
            path:'b/:c',
            component: foo,
          }
      ]
},
  1. No matter we use any method to push router, the URL will not change. For example:
    this.$router.push("/foo/a/b/d"); The URL is still "/foo/a/b/c"

I think these two problems are the same bugs: the nested params or query in the URL not changes when push to the CURRENT URL .

_But the pushed data can be fetched in the "beforeRouteUpdate", the only problem is the URL does not changed._

  • The non-nested params works fine and we can use the "beforeRouteUpdate" to fetch the new params
  • If we push to another URL, it will work fine

Most helpful comment

You likely just forgot to call next() in beforeRouteUpdate

All 6 comments

Hello, your issue has been closed because it does not conform to our issue requirements. Please use the Issue Helper to create an issue - thank you!

You likely just forgot to call next() in beforeRouteUpdate

Wow...I am so careless and spend a lot of time doing test...Thank you so so much! @LinusBorg

@LinusBorg, Big thanks from 2018 ! :)

@LinusBorg, Big thanks from 2019 ! :)

@LinusBorg You're the man :smile:

Was this page helpful?
0 / 5 - 0 ratings