getLocation(lng,lat){
let city = '';
new BMap.Geocoder().getLocation(new BMap.Point(this.parse(lng), this.parse(lat)), rs => {
city = rs.addressComponents.city;
});
return city;
}
函数不能实时输出city 因为getlocation是异步的 如何才能实现同步输出呢?
用Promise ,方法如下:
如果帮到你,希望采纳,谢谢