代码如下:
const [err, loc] = await uni.getLocation({
type: 'gcj02'
});
if (err) {
console.log(err)
}
返回err,打印如下:
“{ "errMsg": "getLocation:fail Cannot read properties of undefined (reading 'then')" }”
初学者,请教大神指点,多谢!
3 个回复
DCloud_UNI_JBB
H5 需配置定位 SDK 信息才可支持 gcj02,参考官方文档 https://uniapp.dcloud.net.cn/api/location/location.html#getlocation
爱豆豆 - 办法总比困难多
getLocation不是Promise对象
可以用成功回调获取到返回数据
参考文档:https://uniapp.dcloud.net.cn/api/location/location.html
用户2877307 (作者)
@爱豆豆 谢谢,参照您的建议修改如下:
仍然报原来的错: