当前位置: 首页 > Web前端 > vue.js

vue-router如何保持实时地址不变,动态替换路由参数(地址栏参数)

时间:2023-04-01 00:52:49 vue.js

动态替换修改url参数,可以使用webpack-merge包完成1.安装npminstallwebpack-merge-D2。引用:importmergefrom'webpack-merge'3.使用方法:1??添加一个idthis.$router.push({query:merge(this.$route.query,{'id':'123'})})2??修改idthis.$router.push({query:merge(this.$route.query,{'id':'456'})})3??替换所有idthis.$router.push({query:merge({},{'userId':'xxx123456'})})最后添加location.reload(),刷新当前页面并跳转。特别鸣谢博主:https://www.jianshu.com/p/b9e...