首頁  >  問答  >  主體

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.

迷茫迷茫2741 天前849

全部回覆(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
  • 取消回覆