我正在使用 Capacitor 版本 3,并且正在嘗試 Motion Api。
在此處的檔案中,AccelListenerEvent 帶有一些我想設定的屬性,但沒有關于如何使用它的示例。
所以我使用的部分是 addListener('orientation', ...)
我基本上想設定間隔。
我已經添加了這個:
import { Component } from '@angular/core';
import { PluginListenerHandle } from '@capacitor/core';
import { Motion, AccelListenerEvent } from '@capacitor/motion';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage {
accelHandler: PluginListenerHandle;
accelListenerEvent: AccelListenerEvent;
constructor() {
this.accelListenerEvent.interval = 10;
}
但它在建構式中不喜歡它。
有人對如何設定這些屬性有任何想法嗎?
uj5u.com熱心網友回復:
您可以通過以下方式訪問屬性:
Motion.addListener('accel', event => {
console.log('Interval:', event.interval);
});
由于這是一個事件,您只能接收值,而不能設定它們。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/460330.html
上一篇:如何在Ionic5中自我解除模態
