我从https://github.com/NeoLSN/cordova-plugin-gyroscope实现了陀螺仪,然后,当我将它作为一个角度导入时,我得到了
找不到名称“构造函数”。以及其他有关从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);
});发布于 2021-02-08 17:05:13
需要在app.module.ts中导入的
import { Gyroscope, GyroscopeOrientation, GyroscopeOptions } from '@ionic-native/gyroscope/ngx';添加到ngmodule的
@NgModule({
...
...
...
providers: [....,Gyroscope],
})在完成这些步骤之后,您应该就完成了。
https://stackoverflow.com/questions/64948593
复制相似问题