主体页面代码:

<div class="open" @click="open()">打开新窗口带参数</div>
  methods: {
    open () {
      const {href} = this.$router.resolve({
        path: '/novelList',
        query: {
          pdf: 77
        }
      })
      window.open(href, '_blank')
    }
  }

新窗口页面接受参数:

 created() {
    this.getParams();
  },
  methods: {
    getParams() {
      // 取到路由带过来的参数
      const routerParams = this.$route.query.pdf;
      console.log("接受的pdf的值:", routerParams);
     }
  }

注意: “const routerParams = this.$route.query.pdf;”,中的pdf与主体页面query中的pdf一致;

Logo

前往低代码交流专区

更多推荐