Installation

Direct Download / CDN

https://unpkg.com/vuexInstallation - 图1 (opens new window)

Unpkg.comInstallation - 图2 (opens new window) provides NPM-based CDN links. The above link will always point to the latest release on NPM. You can also use a specific version/tag via URLs like https://unpkg.com/vuex@2.0.0.

Include vuex after Vue and it will install itself automatically:

  1. <script src="/path/to/vue.js"></script>
  2. <script src="/path/to/vuex.js"></script>

NPM

  1. npm install vuex --save

Yarn

  1. yarn add vuex

When used with a module system, you must explicitly install Vuex as a plugin:

  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. Vue.use(Vuex)

You don’t need to do this when using global script tags.

Promise

Vuex requires PromiseInstallation - 图3 (opens new window). If your supporting browsers do not implement Promise (e.g. IE), you can use a polyfill library, such as es6-promiseInstallation - 图4 (opens new window).

You can include it via CDN:

  1. <script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.auto.js"></script>

Then window.Promise will be available automatically.

If you prefer using a package manager such as NPM or Yarn, install it with the following commands:

  1. npm install es6-promise --save # NPM
  2. yarn add es6-promise # Yarn

Furthermore, add the below line into anywhere in your code before using Vuex:

  1. import 'es6-promise/auto'

Dev Build

You will have to clone directly from GitHub and build vuex yourself if you want to use the latest dev build.

  1. git clone https://github.com/vuejs/vuex.git node_modules/vuex
  2. cd node_modules/vuex
  3. npm install
  4. npm run build