我想在我的Laravel应用中通过GoogleMaps API集成地图。因此我选择了这样的设置:
HTML
(...)
<body>
<div class="wrapper wrapper-content animated fadeInRight">
<div id="app">
</div>
</div>
<script src="https://maps.googleapis.com/maps/api/js?key=[APIKEY]&libraries=places,geometry&callback=app.init" async defer></script>
</body>
(...)
Javascript VUE
window.Vue = Vue;
window.Event = new class {
constructor() {
this.Vue = new Vue();
}
fire(event, data = null) {
this.Vue.$emit(event, data);
}
listen(event, callback) {
this.Vue.$on(event, callback);
}
};
window.app = new Vue({
el: '#app',
components: {
GISView: GISView
},
data: {
},
methods: {
init: function() {
this.$broadcast('MapsApiLoaded');
}
}
});
为什么没有找到app.init函数,因为我已经在我的VUE实例中设置了它?