美文网首页
DeviceOrientationEvent is not de

DeviceOrientationEvent is not de

作者: 薯条你哪里跑 | 来源:发表于2020-12-29 15:46 被阅读0次

    背景

    开发vr全景展现的功能,需要申请陀螺仪的权限,但是在浏览器里测试是却报错了,查了一下属性的兼容性发现没有问题。

    image.png

    解决

    新开了一个标签页,在控制器里输出 DeviceOrientationEvent 发现是个正常的function。 但是自己的页面就是不行,突然发现本地起来页面是用http的协议,部署到测试环境使用https,发现不会报错,猜测报错和安全协议有关。本地使用 localhost也是可以的。

    Because Generic Sensor API is a powerful feature, Chrome only allows it on secure contexts. In practice it means that to use Generic Sensor API you'll need to access your page through HTTPS. During development you can do so via http://localhost but for production you'll need to have HTTPS on your server. See Security with HTTPS article for best practices and guidelines there.

    相关文章

      网友评论

          本文标题:DeviceOrientationEvent is not de

          本文链接:https://www.haomeiwen.com/subject/nhafoktx.html