vue.js 多router嵌套路由时如果带redirect参数无法传递

1 router 环境
两个router嵌套: bookRouter -> chapterRouter 对应URL为: /book/chapter
其中chapterRouter配置了redirect, 到page0组件,url为 /book/chapter/page0

      path: '/chapter',
      redirect: 'chapter/page0',

2 router client环境:
在非上述router的页面, 如 /trial 页面,点击页面button试读,并传递参数 doc (是个js Object)

this.$router.push({name: 'chapterRouter', params: {doc: this.doc}})

3 运行问题
在 bookRouter 、chapterRouter、Page0 组件的mounted 函数都尝试接受param, 但都收不到:

  mounted: function () {
    console.info('mounted')
    console.info(this.$route.params.doc)
  }

4 正常情况.
但是,如果chapterRouter没有设置redirect, bookRouter 和 chapterRouter mounted 都能收到 doc object参数

阅读 2.2k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题