typescript - 未捕获的类型错误:无法读取未定义的属性“振动”
问题描述
下午好,对不起,我的英语不好,我的离子电容器有问题,我正在尝试使用插件 Vibration,文档没有描述太多东西,但我从 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);
}
}
}
解决方案
如果您使用 Capacitor 构建应用程序,最好尽可能使用电容器插件。对于振动,您可以使用电容器Haptics 插件
推荐阅读
- javascript - 在组件之间传递值:传递引用与主题
- visual-studio-2019 - 在 Visual Studio 2019 项目的文件夹中自动包含文件
- jquery - 表格的粘性按钮宽度,位于页脚上方
- python - 在 Matplotlib 中为条形图指定 x 坐标有什么用?
- c# - WPF Checkbox.Checked 事件在加载数据网格之前触发
- c++ - 将 std::iterator 用作类变量时出现分段错误
- javascript - 如何使用 npm 的 csvtojson 将 csv 转换为 json 并忽略 csv 中的第一行?
- jquery - 如何从列表中隐藏选定的选项
- apache - 作为其他域访问的 apache 虚拟主机 - 如何停止它?
- javascript - 如何使用原始样式打印 HTML 元素?