Vue modify the route to solve the query string (query) url does not change, the page does not refresh problem

My personal guess is probably data to detect deep enough to route it, simply modify the query inside the property is not triggered data-driven, so be directly assigned to the query object to the new drive data update, the following practices

The first

 var query=JSON.parse(JSON.stringify(this.$route.query))
query.id="success"
this.$router.push({path:'/url',query:query})

 

The second

var query={id:'123456'}
this.$router.push({path:'/',query:query})

Both methods are similar, the principle is to query the new object, rather than modifying the query property values, because nature is a query object address, point to heap storage space for the object, change the heap space, query value does not change, so route would think that the data is not changed without updating the route.

Guess you like

Origin www.cnblogs.com/shuen/p/10929837.html