1
我有問題來解析數據從addListener到另一個函數,我嘗試但'數據'解析失敗。能不能幫我傢伙...如何解析addListener中的數據javascript
這是我的代碼
var data = 'myname';
bermudaTriangle.addListener('click', showArrays(data);
function showArrays(event, data) {
// Since this polygon has only one path, we can call getPath() to return the
// MVCArray of LatLngs.
var vertices = this.getPath();
var contentString = data;
// Replace the info window's content and position.
infoWindow.setContent(contentString);
infoWindow.setPosition(event.latLng);
infoWindow.open(map);
}
你傳遞給聽衆的'showArrays(數據)調用的結果'但是你只需要參考'bermudaTriangle.addListener( '點擊',showArrays);' – MysterX
你需要檢查你的語法... – gcampbell