【发布时间】:2012-06-09 16:11:05
【问题描述】:
我有代码:
country: (origin) ->
@geocoder = new google.maps.Geocoder
@geocoder.geocode(
'latLng': origin,
(results, status) =>
if status is google.maps.GeocoderStatus.OK
return results[6]
else alert("Geocode was not successful for the following reason: " + status);
)
我在backbone.js中称它为:
test = @country(origin)
console.log(test)
作为测试,我正在使用 console.log。但是我得到了一个:
undefined
response,因为 country 函数没有返回任何内容。我知道 results[6] 中有数据,因为我可以在那里做一个 conolse.log 并返回。
如何让 country 函数在调用时返回 result[6]?
【问题讨论】: