#I am facing an issue where the value of this.zuobiao is not being logged after I call the function that assigns a value to it. Why is this happening?
getUserProfile() {
uni.getLocation({
type: 'gcj02 ',
geocode: true,
success: (res) => {
this.showAddress(res.longitude,res.latitude)
console.log(this.zuobiao); // The value of this.zuobiao is empty, why?
uni.showModal({
content: '坐标:' + this.zuobiao
})
}
});
},
showAddress(longitude, latitude) {
const qqmapsdk = new QQMapWX({
key: 'PU7BZ-42SKX-SVF4G-PE7K2-ZMFD7' //Enter your own key here
});
// Tencent map API call
qqmapsdk.reverseGeocoder({
location: {
latitude: latitude,
longitude: longitude
},
success: (res) => {
this.zuobiao = res.result.address // Value has been retrieved
}
});
}
I have tried using async await and promise.then but they did not work. How can I successfully store res.result.address in this.zuobiao?