gpt4 book ai didi

cordova - ionic 3 Location Accuracy Get Error Object(...) 不是函数

转载 作者:行者123 更新时间:2023-12-04 01:47:42 25 4
gpt4 key购买 nike

我已尝试遵循文档插件位置准确性 ionic location accurary 并在新的全新安装程序 ionic 3 中复制粘贴代码

安装插件:

ionic cordova 插件添加 cordova-plugin-request-location-accuracy
npm install @ionic-native/location-accuracy

在 app.module.ts 和顶级组件中导入

从“@ionic-native/location-accuracy/ngx”导入 { LocationAccuracy }

constructor(private locationAccuracy: LocationAccuracy) { }

按钮点击方法

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(...) is not a function at LocationAccuracy.canRequest (http://localhost:8100/build/vendor.js:79864:133)

解决方案是什么?

最佳答案

看起来你安装了 Ionic 4 的插件。我也做了同样的事情。

你只需要安装正确的插件:

$ npm install --save @ionic-native/location-accuracy@4

导入语句实际上是

import { LocationAccuracy } from '@ionic-native/location-accuracy';

Here is the ionic 3 documentation

关于cordova - ionic 3 Location Accuracy Get Error Object(...) 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54605124/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com