我正在使用VueJS和GoogleMaps在地圖上執行操作。因此,我寫了這個功能設置:函數內的Javascript函數調用
methods: {
// Init GIS
init: function() {
initGISMap(this.$els.map);
},
updateGIS: function() {
getAutoCompletePlace(function(place){
searchMarker.setPosition(place.geometry.location);
autocompletePlace = place;
if (place.geometry.viewport) {
map.fitBounds(place.geometry.viewport);
} else {
map.setCenter(place.geometry.location);
map.setZoom(17);
}
self.updateIncidentForm();
});
},
updateIncidentForm: function() {
console.log("UpdateIncidentForm");
getAddressComponents(function(components) {
this.autoCompleteAddress = components;
this.setIncidentAddressFields(components);
});
},
(...)
我想打電話給updateIncidentForm
功能,getAutocompletePlace
進行時。我在控制檯中得到的錯誤是:
bundle.js:11073 Uncaught TypeError: self.updateIncidentForm is not a function
這很奇怪,因爲它是代碼中定義的函數?我需要以不同的方式調用函數嗎?
你的'var self'在哪裏? –