问题:当你动态修改了A页面的query参数,然后更新A页面路由,然后跳转到B页面,B页面异步操作this.$router.go(-1),此时在A页面获取不到query参数;
解决:A页面需要延迟获取query参数,使用setTimeout(()=>{}, 0),即可正常获取query参数;
如图所示:
mounted() {
this.getApi();
this.createPermission();
setTimeout(() => {
const { moduleType } = this.$route.query;
this.moduleType = moduleType || "touchedInstructions";
console.log(window.location.href);
}, 0);
console.log(window.location.href);
},