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

【feature】希望Taro提供H5的getLocation功能 #11431

Closed
Ghewww opened this issue Mar 11, 2022 · 11 comments · Fixed by #11616
Closed

【feature】希望Taro提供H5的getLocation功能 #11431

Ghewww opened this issue Mar 11, 2022 · 11 comments · Fixed by #11616
Labels
A-api Area - H5 API 相关 enhancement New feature or request T-h5 Target - 编译到 H5

Comments

@Ghewww
Copy link

Ghewww commented Mar 11, 2022

这个特性解决了什么问题?

通过代码和文档发现目前H5不支持getLocation API,不清楚目前没有支持的原因,希望支持。
代码如下:https://github.com/NervJS/taro/blob/next/packages/taro-h5/src/api/location/index.ts#L15

这个 API 长什么样?

与小程序一样,支持Taro.getLocation({})调用

@github-actions
Copy link
Contributor

等待热心的小伙伴解决问题中..., 有一些相关的 issues 可能帮助到你!

Thank you so much!

@SyMind
Copy link
Member

SyMind commented Mar 11, 2022

@ZakaryCode 我也有这个问题,为什么位置相关的方法,在h5中仅支持微信公众号?我们看起来是可以对其进行支持的。

@Chen-jj Chen-jj added enhancement New feature or request A-api Area - H5 API 相关 T-h5 Target - 编译到 H5 labels Mar 12, 2022
@SyMind
Copy link
Member

SyMind commented Mar 14, 2022

@Ghewww 如有时间的话,欢迎pr。

@FE92star
Copy link
Contributor

事实上h5原生的Geolocation对象就支持获取设备地理位置,相当于要把这个h5对象调用集成到Taro.getLocation的API中

@tourze
Copy link
Contributor

tourze commented Mar 14, 2022

如果能提供一个在运行时覆盖Taro自带API的办法,这种问题就没那么多咯

@SyMind
Copy link
Member

SyMind commented Mar 14, 2022

@tourze 或许可以说一说你具体的想法。

@Ghewww
Copy link
Author

Ghewww commented Mar 21, 2022

@SyMind 好~感谢提醒

@tourze
Copy link
Contributor

tourze commented Mar 23, 2022

@tourze 或许可以说一说你具体的想法。

例如:

import Taro from '@tarojs/taro';

Taro.getLocation = console.error;
Taro.login = () => {
    console.warn('H5环境不支持login方法')
};

现在 @tarojs/taro 导出的对象是不能修改的

@ZakaryCode
Copy link
Contributor

@ZakaryCode 我也有这个问题,为什么位置相关的方法,在h5中仅支持微信公众号?我们看起来是可以对其进行支持的。

早期实现,已经不可考 😂
确实是可以新增一下支持

@ZakaryCode
Copy link
Contributor

如果能提供一个在运行时覆盖Taro自带API的办法,这种问题就没那么多咯

其实直接覆盖就行,不过通过 Taro 插件覆盖 H5 提供的 API 目前还不支持,后续可以考虑

@CaiDingxian
Copy link
Contributor

巧了,我也遇到这个问题,已提交PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-api Area - H5 API 相关 enhancement New feature or request T-h5 Target - 编译到 H5
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

7 participants