- Cannot assign to read only property 'exports' of object '#<Object>'
原因:webpack 2中不允许混用import和module.exports。在js文件中可以混用require和export。但是不能混用import 以及module.exports。
解决办法:统一改成ES6的方式编写:不使用module.exports,使用export/export default。
- Cannot read property 'getters' of undefined
原因:类似于找不到getters,actions,mutations之类的,甚至有遇到mapGetters找不到,很多情况是:
import * as actions from './actions';
import * as getters from './getters';
或者:
import { mapActions, mapGetters } from 'vuex';
以上代码没有写对。
我遇到的问题是因为在我的目录结构下store是我自己建的一个文件夹,而用vue create命令初始化下来的项目本身有store.js文件,我在main.js中引用方式是:
import store from './store';
所以导致去寻找store.js,而没有找到store目录下的index.js。
解决办法:单独写了store,就把store.js删掉。