【问题标题】:Cordova (Android) device motion and device orientation (W3C) not availableCordova (Android) 设备运动和设备方向 (W3C) 不可用
【发布时间】:2020-01-24 03:18:37
【问题描述】:

我正在尝试在 Cordova 应用程序中使用 W3C device orientation 和设备运动,因为 plugins 现在已弃用。但是window中没有定义DeviceOrientationEvent,添加这个sn-p时也没有触发事件:

window.addEventListener("deviceorientation", function(event) {
    // process event.alpha, event.beta and event.gamma
}, true);

以下是我的 Android 设备的一些规格:

Device model: JSN-L23
Cordova version: 8.0.0
Device platform: Android
Device manufacturer: HUAWEI
Device version: 9
WebGL support: true
User agent: Mozilla/5.0 (Linux; Android 9; JSN-L23 Build/HONORJSN-L23; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.132 Mobile Safari/537.36
Android WebView package name: com.google.android.webview
Android WebView version code: 372913600
Android WebView version name: 74.0.3729.136

【问题讨论】:

    标签: android cordova devicemotion


    【解决方案1】:

    在 ondeviceready 外部使用,在 deviceready 被触发后,此事件会以某种方式从 windows 对象中消失

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-12-02
      • 1970-01-01
      • 2018-08-20
      • 1970-01-01
      • 2020-12-04
      • 2020-06-27
      • 1970-01-01
      相关资源
      最近更新 更多