【发布时间】:2025-12-22 21:05:06
【问题描述】:
我正在使用带有 ionic2 的地理定位插件。当应用程序在浏览器中加载时,它会请求许可。但是在调用 getcurrentposition 时它并没有得到位置。我用的是火狐浏览器。
控制台日志显示错误:
例外:未捕获(承诺):错误
我需要根据 getcurrentlocation 调用的成功或失败将位置(如果可用)或 null 传递给另一个函数。
这里是sn-p的代码:
public test(){
Geolocation.getCurrentPosition().then((resp) => {
console.log (resp.coords.latitude);
console.log (resp.coords.longitude);
this.callclockin(resp.coords.latitude, resp.coords.longitude);
}).catch((error) => {
this.callclockin("", "");
});
}
【问题讨论】:
标签: ionic-framework firefox-addon ionic2