onShow(() => {
initPageData();
});
// 在initPageData中使用了 uni.getLocation
const handleGetPosition = () =>
new Promise((resolve, reject) => {
uni.getLocation({
type: 'wgs84',
success(res: { longitude: number; latitude: number }) {
resolve(res);
console.log('>>>>>>print me 获取地理位置 >>>>success<<<<', res);
},
fail: (err) => {
reject(err);
},
});
});
const initPageData = async ()=>{
const res = await handleGetPosition();
console.log(res);
}
1 个回复
DCloud_UNI_Anne
用最新HBuilderX3.8.11-alpha试试,相关问题:https://ask.dcloud.net.cn/question/173414