我正在使用电容版本3,我正在尝试运动应用程序。
在文档这里中,AccelListenerEvent附带了一些我想设置的属性,但是没有关于如何使用它的示例。
所以我使用的部分是addListener(“定位”,…)
我基本上是想设定时间间隔。
我补充说:
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;
}但它不喜欢构造函数。
有没有人对如何设置这些属性有任何想法?
发布于 2022-04-11 15:02:57
您可以通过以下方式访问这些属性:
Motion.addListener('accel', event => {
console.log('Interval:', event.interval);
});因为这是一个事件,所以只能接收值,而不能设置值。
https://stackoverflow.com/questions/71828349
复制相似问题