关于vue-router:vuerouter如何实时地址不变动态替换路由参数地址栏参数

5次阅读

共计 395 个字符,预计需要花费 1 分钟才能阅读完成。

动静替换和批改 URL 的参数,可应用 webpack-merge 包来实现
1. 装置 npm install webpack-merge -D
2. 援用:import merge from ‘webpack-merge’
3. 应用办法:

1⃣️新增一个 id

 this.$router.push({query:merge(this.$route.query,{'id':'123'})
})
2⃣️ 批改 id
this.$router.push({query:merge(this.$route.query,{'id':'456'})
})
3⃣️ 替换所有 id
this.$router.push({query:merge({},{'userId':'xxx123456'})
})

最初再加上 location.reload(),刷新一下以后页面就跳转过来了

特别感谢一下博主:https://www.jianshu.com/p/b9e…

正文完
 0