Vue-router: Function or bug ?

Created on 8 Apr 2017  路  2Comments  路  Source: vuejs/vue-router

Version

2.3.0

Reproduction link

https://jsfiddle.net/sciooga/rahhqu0o/

Steps to reproduce

click navigate1 and navigate2 button

What is expected?

change query every times

What is actually happening?

navigate1 return a str and just change once

Most helpful comment

@sciooga
let query = JSON.parse(JSON.stringify(this.$route.query))
Not pretty, but effective.

All 2 comments

$route.query is considered immutable. The router compares the new query against the old query - however because you mutated the old query and passed it to router.push, the comparison is basically comparing the same object to itself.

Cloning is the correct way to do it.

@sciooga
let query = JSON.parse(JSON.stringify(this.$route.query))
Not pretty, but effective.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gil0mendes picture gil0mendes  路  3Comments

shinygang picture shinygang  路  3Comments

posva picture posva  路  3Comments

alexstanbury picture alexstanbury  路  3Comments

achen224 picture achen224  路  3Comments