继续,这次尝试逐行理解Store类的东西
然后关于这次,一些“工具函数”都集中在util.js
的这种做法,已经够我学的了。这是个很受用的做法。
一些简单的东西
if (process.env.NODE_ENV !== 'production') {
assert(Vue, `must call Vue.use(Vuex) before creating a store instance.`)
assert(typeof Promise !== 'undefined', `vuex requires a Promise polyfill in this browser.`)
assert(this instanceof Store, `Store must be called with the new operator.`)
} // 断言函数在util,如果不满足前面的情况,后面以error 排出来
// (实际上就是想看有没有在vue环境中和有没有正确安装)
const {
plugins = [],
strict = false
} = options // 定义两个变量,在传入的对象中把这两个东西拿出来,字面意思