JS
return {
latitude: "123",
longitude: "123",
}
sd() {
wx.getFuzzyLocation({
type: 'wgs84',
success(res) {
let temporarySetTimeout = setTimeout(() => {
this.latitude = res.latitude
this.longitude = res.longitude
console.log(this.latitude)
console.log(this.longitude)
}, 1000)
},
fail(err) {
wx.showToast({
title:"获取定位失败,请先打开手机定位",
icon:"none",
duration:2000,
})
}
})
},
html
<view class="" @click="sd">
{{latitude}}
{{longitude}} {{longitude}}
</view>
控制台有输出的说明修改成功
问题已解决,是this指向问题 小错误不应该, 使用that即可