【发布时间】:2022-08-05 00:33:38
【问题描述】:
我正在尝试在nativescript-vue android 应用程序中使用@nativescript/geolocation。通过调用 getCurrentLocation 方法,如下面的代码所示。
import * as geolocation from \'@nativescript/geolocation\'
import { CoreTypes } from \'@nativescript/core\'
CoreTypes.Accuracy // used to describe at what accuracy the location should be get
...
methods: {
onLoaded(){
console.log(\'>>>>>>>>>>>>>>> : loaded \')
geolocation.getCurrentLocation({
desiredAccuracy: Accuracy.high,
maximumAge: 5000,
timeout: 20000
})
.then(res => {
console.log(\'LOACATION >>>>>>>>>>.>>>>> : \', res)
})
.catch(err => {
console.log(\'LOACATION ERROR >>>>.>>>>> : \', err)
})
}
}
我收到此错误:Error: Cannot enable the location service. TypeError: Cannot read property \'Accuracy\' of undefined
我也尝试使用 tns-core-modules 而不是 \'@nativescript/core\'
import { Accuracy } from \"tns-core-modules/ui/enums\";
但它不起作用
标签: geolocation nativescript nativescript-vue