登录

html5 - http是否不支持h5 Geolocatio

用本机ip访问无法获取坐标,用localhost访问倒是可以,有人遇到过吗

换成https也可以,但是就是http的不行

报错:
getCurrentPosition() and watchPosition() no longer work on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.

# HTML
迷茫迷茫2098 天前597 次浏览

全部回复(2) 我要回复

  • 伊谢尔伦

    伊谢尔伦2017-04-17 13:57:30

    从chrome 50开始就不支持http的方式访问了, 需要切换成https
    你本机搭的服务器 localhost 本身就被认为是安全的,类同https, 所以本地服务器跑是能够用来测试的
    如果一定要用的话 可以设置这样看看

    1、修改安全策略   --unsafely-treat-insecure-origin-as-secure="http://example.com" flag (假设"example.com" 就是你要跑的域名),
    --user-data-dir=C:\testprofile

    回复
    0
  • 巴扎黑

    巴扎黑2017-04-17 13:57:30

    这个api本地是不能用的。

    回复
    0
  • 取消回复发送