小程序
小游戏
企业微信
微信支付
扫描小程序码分享
iOS 微信版本7.0.12 陀螺仪失效
访问链接:https://shellsvp.nn.cagoe.com/test.html
预期表现:不停刷新 deviceorientation 事件回调的 event.beta 以及下方输出 1
测试微信版本7.0.12 实际结果为 只输出了1,没有更新event.beta
微信版本 7.0.11 符合预期
2 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
https://stackoverflow.com/questions/56514116/how-do-i-get-deviceorientationevent-and-devicemotionevent-to-work-on-safari
function permission () { if ( typeof( DeviceMotionEvent ) !== "undefined" && typeof( DeviceMotionEvent.requestPermission ) === "function" ) { // (optional) Do something before API request prompt. DeviceMotionEvent.requestPermission() .then( response => { // (optional) Do something after API prompt dismissed. if ( response == "granted" ) { window.addEventListener( "devicemotion", (e) => { // do something for 'e' here. }) } }) .catch( console.error ) } else { alert( "DeviceMotionEvent is not defined" ); } }
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
微信版本 7.0.11以下版本是不是不需要用户授权的呀?
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
https://stackoverflow.com/questions/56514116/how-do-i-get-deviceorientationevent-and-devicemotionevent-to-work-on-safari
function permission () { if ( typeof( DeviceMotionEvent ) !== "undefined" && typeof( DeviceMotionEvent.requestPermission ) === "function" ) { // (optional) Do something before API request prompt. DeviceMotionEvent.requestPermission() .then( response => { // (optional) Do something after API prompt dismissed. if ( response == "granted" ) { window.addEventListener( "devicemotion", (e) => { // do something for 'e' here. }) } }) .catch( console.error ) } else { alert( "DeviceMotionEvent is not defined" ); } }
.then( response => {
// (optional) Do something after API prompt dismissed.
if ( response == "granted" ) {
window.addEventListener( "devicemotion", (e) => {
// do something for 'e' here.
})
}
})
.catch( console.error )授权成功后就可以用了
微信版本 7.0.11以下版本是不是不需要用户授权的呀?