2017-05-12 66 views

回答

0

它由export default引起的。嘗試直接輸出const。

例子:

store.js

import 'Vue' from 'vue'; 
import 'Vuex' from 'vuex'; 

Vue.use(Vuex); 

export const store = new Vuex.Store({ 
    state: { 
    //your code here// 
    } 
}); 

Main.js

import 'store' from 'wherever the file is/mystore.js'; 

new Vue({ 
    el: '#app', 
    store, <-- Here is defined store to use along the my app 
    render: h => h(App) 
}); 
+0

它的作品,我非常感謝你們的幫助,它解決了我的難題幾天,但是當我使用'export default'時,我仍然感到困惑,如果使用必須的話,它會犯錯誤使用'export default'然後如何寫它 – whyang

+0

得到它,如果我用''export {store}''',它會沒事的,我應該仔細閱讀es6模塊,再次感謝你給我一個方向, – whyang