Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(h5): Router解析出来的params供赋值给getCurrentInstance()?.router?.params #11545

Merged
merged 5 commits into from
May 5, 2022

Conversation

Gzxing
Copy link
Contributor

@Gzxing Gzxing commented Mar 31, 2022

这个 PR 做了什么? (简要描述所做更改)
问题:
H5上类似 “'/swift/:regionType/:dcity/:acity/:ddate'” 这种路由能够被Router解析出来,但是解析出来的参数无法获取到。

解决方案:
修改taro-loader生成H5的路由代码中load 增加返回参数routerContext 和routerParams
修改taro-router获取到routerContext 和routerParams 后传递给createPageConfig并赋值给options

现有代码上PageConfig的options会赋值给getQuery函数最终能够通过 getCurrentInstance()?.router?.params 获取到

这个 PR 是什么类型? (至少选择一个)

这个 PR 涉及以下平台:

  • 所有小程序
  • 微信小程序
  • 支付宝小程序
  • 百度小程序
  • 字节跳动小程序
  • QQ 轻应用
  • 京东小程序
  • 快应用平台(QuickApp)
  • Web 平台(H5)
  • 移动端(React-Native)

@taro-bot2
Copy link

taro-bot2 bot commented Mar 31, 2022

欢迎提交 PR~ Taro 非常感谢您对开源事业做出的贡献!🌷🌷🌷

一般 PR 会在一到两周内进行 review,成功合入后会随下一个版本进行发布。

Review 需要耗费大量时间,所以请遵循以下规范,协助我们提高 review 效率🙏🙏🙏

  1. 详细介绍 PR 的背景(非常重要,例如解决了什么问题,该问题如何复现等)
  2. 确保 CI 顺利运行。
  3. 最好能提供对应的测试用例。

为了更好地进行沟通,请加入 Taro 开发者微信群:

@ZakaryCode ZakaryCode self-requested a review March 31, 2022 08:01
@ZakaryCode ZakaryCode added A-router Area - H5 路由相关 V-3 Version - 3.x T-h5 Target - 编译到 H5 labels Mar 31, 2022
@ZakaryCode ZakaryCode changed the base branch from next to feat/webpack5 April 14, 2022 06:26
@ZakaryCode
Copy link
Contributor

解决方案: 修改taro-loader生成H5的路由代码中load 增加返回参数routerContext 和routerParams 修改taro-router获取到routerContext 和routerParams 后传递给createPageConfig并赋值给options

这并不是一个新功能,更新到最新版本已有该特性

@ZakaryCode ZakaryCode closed this Apr 19, 2022
@Gzxing
Copy link
Contributor Author

Gzxing commented Apr 20, 2022

抱歉,我刚更新到3.4.7版本测试了一下,然后又趴了最新的代码看了,并没看到哪里会怕路由上解析出来的参数传出来。
有相关文档吗?或者相关代码路径也行。@ZakaryCode

@ZakaryCode
Copy link
Contributor

抱歉,之前理解错了 😂

@ZakaryCode
Copy link
Contributor

不过这个功能实现也会在下一个版本上

@Gzxing
Copy link
Contributor Author

Gzxing commented Apr 22, 2022

多谢 :)

@ZakaryCode ZakaryCode changed the base branch from feat/webpack5 to feat/3.5 April 22, 2022 13:55
@ZakaryCode ZakaryCode force-pushed the fix/h5-router-params branch from 2a495f9 to b9efe4c Compare May 5, 2022 10:43
Copy link
Contributor

@ZakaryCode ZakaryCode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢贡献

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-router Area - H5 路由相关 T-h5 Target - 编译到 H5 V-3 Version - 3.x
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants