vue如何动态更换地址栏的参数
watch: { id (val) { let query = this.$router.history.current.query; let path = this.$router.history.current.path; //对象的拷贝 let newQuery = JSON.parse(JSON.stringify(query)); newQuery.id = val; //地址栏的参数值 this.$router.push({ path, query: newQuery }); } }, 我的需求是,点击切换上下篇文章,我就在地址栏添加了参数,但是切换刷新后,还是原来的;所以就通过在点击的时候,将值赋值到data里面,然后通过watch监听,将值动态的换到地址栏上去,这样刷新还是原来的啦 来源: https://www.cnblogs.com/chenzhengyang/p/11660078.html