如题,请问如何把闭包里面的形参数据传递给外部变量
var outer;
var map = new BMap.Map("allmap");
var point = new BMap.Point(116.331398,39.897445);
var gc = new BMap.Geocoder();
gc.getLocation(point, function(rs){
var addComp = rs.addressComponents;
//how to store this string to variable outer;
//outer = addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber);
});
使用赋值只能保证在闭包内数据有效,退出后就无效,使用new分配内存也无果,时间仓促来不及学习JS所以厚着脸皮来segmentfault问一下>3<
萧十郎
相关分类