We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
useRouter() 获取不到
useRouter() 能获取到
The text was updated successfully, but these errors were encountered:
自问自答了, 修改app.tsx
onLaunch(option: any) { if (process.env.TARO_ENV === "alipay" && option.query?.qrCode) { // } } componentDidShow(option: any) { if (process.env.TARO_ENV === "alipay" && option.query?.qrCode) { // } }
不知是否有其他方法
Sorry, something went wrong.
@konka-king 都自问自答了,可以尝试自问自修啊 😄
Taro提供的 useRouter 主要用于获取页面链接的查询参数,比如通过 Taro.navigateTo({url:'../index/index?a=1&b=2'}), 你可以通过 useRouter 获取到页面参数 {a: '1', b: '2'}。同理,使用 Taro.getCurrentInstance().router 也是如此。
Taro.navigateTo({url:'../index/index?a=1&b=2'})
{a: '1', b: '2'}
Taro.getCurrentInstance().router
但是,通过扫描二维码启动小程序,要获取二维码中的参数,则需要从 onLaunch 生命周期中获得,通常它长这样: alipays://platformapi/startapp?appId=1999&query=number%3D1&page=x%2Fy%2Fz 参见支付宝文档
alipays://platformapi/startapp?appId=1999&query=number%3D1&page=x%2Fy%2Fz
Taro App组件支持 onLaunch 生命周期 或者 调用 getLaunchOptionsSync()。
getLaunchOptionsSync()
综上,useRouter 符合预期。
useRouter
No branches or pull requests
这个特性解决了什么问题?
useRouter() 获取不到
这个 API 长什么样?
useRouter() 能获取到
The text was updated successfully, but these errors were encountered: