angular - 带有构造函数的陀螺仪离子角度误差
问题描述
我从https://github.com/NeoLSN/cordova-plugin-gyroscope实现了陀螺仪,然后,当我将它作为 Angular 导入时,我得到了
找不到名称“构造函数”。以及有关以下从https://ionicframework.com/docs/native/gyroscope导入的其他错误。
有人有完整版吗?
import { Gyroscope, GyroscopeOrientation, GyroscopeOptions } from '@ionic-native/gyroscope/ngx';
constructor(private gyroscope: Gyroscope) { }
...
let options: GyroscopeOptions = {
frequency: 1000
}
this.gyroscope.getCurrent(options)
.then((orientation: GyroscopeOrientation) => {
console.log(orientation.x, orientation.y, orientation.z, orientation.timestamp);
})
.catch()
this.gyroscope.watch()
.subscribe((orientation: GyroscopeOrientation) => {
console.log(orientation.x, orientation.y, orientation.z, orientation.timestamp);
});
解决方案
- 您需要导入
app.module.ts
:
import { Gyroscope, GyroscopeOrientation, GyroscopeOptions } from '@ionic-native/gyroscope/ngx';
- 添加到ngmodule:
@NgModule({
...
...
...
providers: [....,Gyroscope],
})
在此步骤之后,您应该完成。
推荐阅读
- c# - 打开连接后关闭前执行sql命令
- bash - 使用循环选择目录中的项目
- android - onOptionsItemSelected 不适用于我的菜单
- excel - Excel公式:我如何将真实串联输出的总和放在字符串的末尾
- javascript - 如何treeshake需要多个图像的资产对象(url和文件加载器)
- bash - 如何获取失败的 BashOperator 的退出代码?
- java - 如何连接到 Azure MySQL 数据库
- objective-c - 当我重新运行我的应用程序时,对我的 Assets.xcassets 文件夹所做的更改没有被拾取?
- javascript - 为什么我的带有 JSON 的 Vue for 循环不起作用?
- nestjs - 配置传播到子模块