window.wx.ready(() => {
window.wx.getLocation({
type: 'gcj02',
isHighAccuracy: true, // 精准定位
highAccuracyExpireTime: 3000,
async success(res: any) {
// 获取城市名称
const { bdjLng, bdjLat } = await gcj02ToBd09(Number(res.longitude), Number(res.latitude))
const location = await getLocation(bdjLng, bdjLat)
if (!userProvince.province)
userProvince.updateProvince(location)
},
cancel: async () => {
console.log('微信定位取消的回调')
},
fail: async () => {
console.log('微信定位失败的回调')
}
})
})

你好,用官方示例试试呢?