下午好,我为我糟糕的英语感到抱歉,我有一个离子电容器的问题,我正在尝试使用插件振动,文档没有描述太多的东西,但我从android studio的终端收到了这条消息。
错误:

这是我的代码:
import { Plugins, CameraResultType } from '@capacitor/core';
import { Vibration } from '@ionic-native/vibration/ngx';
const { Camera } = Plugins
interface Props extends React.Props<ControlVibratorComponent> {
}
export default class ControlVibratorComponent extends React.Component<Props>{
constructor(props: any, private vibration: Vibration) {
super(props);
}
changeNotificationState(e: any) {
if (e.detail.value > 0) {
console.log('vibrando');
// this.vibration.vibrate([2000, 1000, 2000]);
// console.log(this.vibration);
this.vibration.vibrate(2000);
} else {
console.log('stop');
this.vibration.vibrate(0);
}
}
}发布于 2020-06-08 15:00:58
如果您正在使用Capacitor构建您的应用程序,最好尽可能使用capacitor插件。对于振动,您可以使用电容器Haptics Plugin
发布于 2020-06-08 07:59:25
我不知道Cordova插件是否能与电容器一起工作。但是如果是这样的话,使用这个插件的步骤如下:
1-添加插件:
ionic cordova plugin add cordova-plugin-vibration2-安装程序包:
npm install @ionic-native/vibration3-在app.module.ts中导入,并添加到providers中:
import {YourPlugin} from './path-to-your-plugin-in-node_modules';
@NgModule({
...
providers: [
...
YourPlugin
...
],
...
})
export class AppModule {
}将其导入您的组件控制器(.page.ts文件)中,并在构造函数中创建其实例并使用其方法:
import {YourPlugin} from './path-to-your-plugin-in-node_modules';
@Component({
selector: 'app-somepage',
templateUrl: './somepage.page.html',
styleUrls: ['./somepage.page.scss'],
})
export class SomepagePage implements OnInit, AfterViewInit {
constructor(private plugin: YourPlugin) {
}
}如果你还做了别的什么,那你就错了。再这样做一次。
https://stackoverflow.com/questions/62252183
复制相似问题