【发布时间】:2017-10-08 10:45:22
【问题描述】:
我有一个简单的演示,我想尝试了解更多关于 VueJS 组件的信息。但是当我加载我的页面时,我收到错误:Unexpected Token Import, in this line
从'./components/GISView.vue'导入GISView;
当我删除它时,没有定义 GISView。我使用 Laravel 5.4 和 webpack 来编译脚本。为什么找不到组件?
Main.js
import GISView from './components/GISView.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');
}
}
});
GISView.vue
<script>
import GoogleMaps from '../mixins/GoogleMaps.js';
export default {
mixins: [GoogleMaps]
}
</script>
我真的被困了好几个小时,因为仅凭代码,我会说它应该可以工作。
【问题讨论】:
-
请发布您的 webpack 配置的 loader 部分
标签: javascript laravel vue.js