Ich möchte ein mixin in meinem VUEJS Modul verwenden:VueJS Mixins Methoden
Modul
<script>
var GoogleMaps = require('../mixins/GoogleMaps');
export default {
mixins: [GoogleMaps],
events: {
MapsApiLoaded: function(data) {
GoogleMaps.initGISMap(data);
}
},
}
</script>
Mixin
export default {
methods: {
initGISMap(selector) {
map = new google.maps.Map(selector, {
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP,
});
// Set initial Location and center map to this location
initialLocation = new google.maps.LatLng(48.184845, 11.252553);
map.setCenter(initialLocation);
// Create a searchmarker
searchMarker = createMarker();
// Init Autocomplete for GIS
initAutoComplete();
}
}
}
Aber ich erhalte eine Fehlermeldung, dass Googlemaps. initGISMap ist keine Funktion. Wie verwende ich eine Mixin-Methode innerhalb einer Komponente?
ich glaube, dass Sie das Mixin mit diesem Bezug nehmen müssen. so im Modul this.GoogleMaps.initGISMAP (Daten) – vbranden