路由本身有query参数,更新了query,也push了,页面url不改变,这个时候其实用到了对象的拷贝,你需要对query对象做拷贝
let query = this.$router.history.current.query;
let path = this.$router.history.current.path;
//对象的拷贝
let newQuery = JSON.parse(JSON.stringify(query));
newQuery.id= id;
this.$router.push({ path, query: newQuery });
博客指出在Vue中,当路由本身有query参数,更新query并执行push操作后,页面URL可能不改变。此时可通过对query对象进行拷贝来解决该问题,涉及对象拷贝的相关操作。
5517

被折叠的 条评论
为什么被折叠?



