值我的代碼:返回從函數的CoffeeScript
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
響應,作爲國家功能不返回任何東西。我知道結果[6]中有數據,因爲我可以在那裏做一個conolse.log,並返回。
如何在調用國家函數時返回結果[6]?
你需要定義handleResult之前嗎?如果是的話,它應該是什麼? –
從來沒有做過延續功能...... –
@CharlieDavies:我用一個簡單的例子來說明如何使用它。 –