美文网首页
异步使用路由this.$router.go(-1) 导致页面参数

异步使用路由this.$router.go(-1) 导致页面参数

作者: 多记录多学习 | 来源:发表于2023-05-17 16:22 被阅读0次

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


image.png
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);
  },
image.png

相关文章

网友评论

      本文标题:异步使用路由this.$router.go(-1) 导致页面参数

      本文链接:https://www.haomeiwen.com/subject/himisdtx.html