Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Webpack ES 6导入Vue_Webpack_Ecmascript 6_Vue.js_Vuejs2 - Fatal编程技术网

Webpack ES 6导入Vue

Webpack ES 6导入Vue,webpack,ecmascript-6,vue.js,vuejs2,Webpack,Ecmascript 6,Vue.js,Vuejs2,我创建了我的服务文件,如下所示: import Vue from 'vue' var service = { counter : 1, loadProducts : function(){ return Vue.http.get('http://www.json-generator.com/api/json/get/cqLJAlYsPm?indent=2'); } } export default service 我已经在我的单个组件中导入了它 &l

我创建了我的
服务
文件,如下所示:

import Vue from 'vue'

var service = {
    counter : 1,
    loadProducts : function(){
        return Vue.http.get('http://www.json-generator.com/api/json/get/cqLJAlYsPm?indent=2');
    }
}

export default service
我已经在我的单个组件中导入了它

<!-- src/components/ProductList.vue -->
<template>
    <table class="table table-hover product-table">
        <thead>
            <tr>
                <th>Name</th>
                <th>Description</th>
                <th>Price</th>
            </tr>
        </thead>
        <tbody>
            <tr v-for="product in products" track-by="id">
                <td>{{product.about}}</td>
                <td>{{product.address}}</td>
                <td>{{product.age}}</td>
            </tr>
        </tbody>
    </table>
</template>

<script>    
    import service from './my-service.js'

export default {
    created: function(){
        service.counter++;
        console.log(service);
        console.log('created');

        service.loadProducts().then(response => {
            this.products = response.data;
        });

    },
  data () {
    return {
        products: []
    }
  }
}
</script>
这会再次包含在我的js文件中吗?所以每次我写import Vue时,我的JS文件都会膨胀

如果我在服务文件[…]中导入Vue,这会再次包含在我的js文件中吗?所以每次我写import Vue时,我的JS文件都会膨胀


如果没有,则为否,
vue
模块将不会多次包含在同一块中。如果您要进行代码拆分,那么您需要跨多个块使用同一模块的to(如果这与您有关)。

非常好。我的设置确实有一个插件。
import Vue from 'vue'