Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vuex 源码研究 #85

Open
xiaotiandada opened this issue Aug 31, 2021 · 0 comments
Open

Vuex 源码研究 #85

xiaotiandada opened this issue Aug 31, 2021 · 0 comments

Comments

@xiaotiandada
Copy link
Owner

xiaotiandada commented Aug 31, 2021

Index.js

import { Store, install } from './store'

导入/导出各个模块功能

Store.js

if (!Vue && typeof window !== 'undefined' && window.Vue) {
	install(window.Vue)
}

在 Vue 环境中安装

if (__DEV__) {
  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.`)
}

开发模式断言

    const {
      // 一个数组,包含应用在 store 上的插件方法。
      plugins = [],
      // 使 Vuex store 进入严格模式,在严格模式下,任何 mutation 处理函数以外修改 Vuex state 都会抛出错误。
      strict = false
    } = options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant