我尝试遵循文档插件位置精度ionic位置精度,并在新的全新安装程序中复制粘贴代码
ionic 4.10.3
cordova 8.1.2
安装插件:
ionic cordova plugin add cordova-plugin-request-location-accuracy
npm install @ionic-native/location-accuracy
import in app.module.ts and top component
import { LocationAccuracy } from '@ionic-native/location-accuracy/ngx';
constructor(private locationAccuracy: LocationAccuracy) { }
button click method
this.locationAccuracy.canRequest().then((canRequest: boolean) => {
if(canRequest) { this.locationAccuracy.request(this.locationAccuracy.REQUEST_PRIORITY_HIGH_ACCURACY).then(
() => console.log('Request successful'),
error => console.log('Error requesting location permissions', error)
);
}
});
但出现错误:
TypeError:Object(...)不是函数 LocationAccuracy.canRequest http://localhost:8100/build/vendor.js:79864:133