installation.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. <!DOCTYPE HTML>
  2. <html lang="en" >
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  6. <title>Installation · Vuex</title>
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  8. <meta name="description" content="">
  9. <meta name="generator" content="GitBook 3.2.2">
  10. <link rel="stylesheet" href="../gitbook/style.css">
  11. <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism.css">
  12. <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
  13. <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-vuejs/vue.css">
  14. <meta name="HandheldFriendly" content="true"/>
  15. <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
  16. <meta name="apple-mobile-web-app-capable" content="yes">
  17. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  18. <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
  19. <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
  20. <link rel="next" href="intro.html" />
  21. </head>
  22. <body>
  23. <div class="book">
  24. <div class="book-summary">
  25. <div id="book-search-input" role="search">
  26. <input type="text" placeholder="Type to search" />
  27. </div>
  28. <nav role="navigation">
  29. <script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?zoneid=1673&serve=C6AILKT&placement=vuejs" id="_carbonads_js"></script>
  30. <ul class="summary">
  31. <li class="chapter " data-level="1.1" data-path="./">
  32. <a href="./">
  33. Introduction
  34. </a>
  35. </li>
  36. <li class="chapter " data-level="1.2" >
  37. <a target="_blank" href="https://github.com/vuejs/vuex/releases">
  38. Release Notes
  39. </a>
  40. </li>
  41. <li class="chapter active" data-level="1.3" data-path="installation.html">
  42. <a href="installation.html">
  43. Installation
  44. </a>
  45. </li>
  46. <li class="chapter " data-level="1.4" data-path="intro.html">
  47. <a href="intro.html">
  48. What is Vuex?
  49. </a>
  50. </li>
  51. <li class="chapter " data-level="1.5" data-path="getting-started.html">
  52. <a href="getting-started.html">
  53. Getting Started
  54. </a>
  55. </li>
  56. <li class="chapter " data-level="1.6" data-path="core-concepts.html">
  57. <a href="core-concepts.html">
  58. Core Concepts
  59. </a>
  60. <ul class="articles">
  61. <li class="chapter " data-level="1.6.1" data-path="state.html">
  62. <a href="state.html">
  63. State
  64. </a>
  65. </li>
  66. <li class="chapter " data-level="1.6.2" data-path="getters.html">
  67. <a href="getters.html">
  68. Getters
  69. </a>
  70. </li>
  71. <li class="chapter " data-level="1.6.3" data-path="mutations.html">
  72. <a href="mutations.html">
  73. Mutations
  74. </a>
  75. </li>
  76. <li class="chapter " data-level="1.6.4" data-path="actions.html">
  77. <a href="actions.html">
  78. Actions
  79. </a>
  80. </li>
  81. <li class="chapter " data-level="1.6.5" data-path="modules.html">
  82. <a href="modules.html">
  83. Modules
  84. </a>
  85. </li>
  86. </ul>
  87. </li>
  88. <li class="chapter " data-level="1.7" data-path="structure.html">
  89. <a href="structure.html">
  90. Application Structure
  91. </a>
  92. </li>
  93. <li class="chapter " data-level="1.8" data-path="plugins.html">
  94. <a href="plugins.html">
  95. Plugins
  96. </a>
  97. </li>
  98. <li class="chapter " data-level="1.9" data-path="strict.html">
  99. <a href="strict.html">
  100. Strict Mode
  101. </a>
  102. </li>
  103. <li class="chapter " data-level="1.10" data-path="forms.html">
  104. <a href="forms.html">
  105. Form Handling
  106. </a>
  107. </li>
  108. <li class="chapter " data-level="1.11" data-path="testing.html">
  109. <a href="testing.html">
  110. Testing
  111. </a>
  112. </li>
  113. <li class="chapter " data-level="1.12" data-path="hot-reload.html">
  114. <a href="hot-reload.html">
  115. Hot Reloading
  116. </a>
  117. </li>
  118. <li class="chapter " data-level="1.13" data-path="api.html">
  119. <a href="api.html">
  120. API Reference
  121. </a>
  122. </li>
  123. <li class="divider"></li>
  124. <li>
  125. <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
  126. Published with GitBook
  127. </a>
  128. </li>
  129. </ul>
  130. </nav>
  131. </div>
  132. <div class="book-body">
  133. <div class="body-inner">
  134. <div class="book-header" role="navigation">
  135. <!-- Title -->
  136. <h1>
  137. <i class="fa fa-circle-o-notch fa-spin"></i>
  138. <a href="." >Installation</a>
  139. </h1>
  140. </div>
  141. <div class="page-wrapper" tabindex="-1" role="main">
  142. <div class="page-inner">
  143. <div id="book-search-results">
  144. <div class="search-noresults">
  145. <section class="normal markdown-section">
  146. <h1 id="installation">Installation</h1>
  147. <h3 id="direct-download--cdn">Direct Download / CDN</h3>
  148. <p><a href="https://unpkg.com/vuex" target="_blank">https://unpkg.com/vuex</a></p>
  149. <!--email_off-->
  150. <p><a href="https://unpkg.com" target="_blank">Unpkg.com</a> 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 <code>https://unpkg.com/vuex@2.0.0</code>.
  151. <!--/email_off--></p>
  152. <p>Include <code>vuex</code> after Vue and it will install itself automatically:</p>
  153. <pre class="language-"><code class="lang-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>/path/to/vue.js<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">&gt;</span></span>
  154. <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>/path/to/vuex.js<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">&gt;</span></span>
  155. </code></pre>
  156. <h3 id="npm">NPM</h3>
  157. <pre class="language-"><code class="lang-bash"><span class="token function">npm</span> <span class="token function">install</span> vuex --save
  158. </code></pre>
  159. <h3 id="yarn">Yarn</h3>
  160. <pre class="language-"><code class="lang-bash">yarn add vuex
  161. </code></pre>
  162. <p>When used with a module system, you must explicitly install Vuex via <code>Vue.use()</code>:</p>
  163. <pre class="language-"><code class="lang-js"><span class="token keyword">import</span> Vue <span class="token keyword">from</span> <span class="token string">&apos;vue&apos;</span>
  164. <span class="token keyword">import</span> Vuex <span class="token keyword">from</span> <span class="token string">&apos;vuex&apos;</span>
  165. Vue<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span>Vuex<span class="token punctuation">)</span>
  166. </code></pre>
  167. <p>You don&apos;t need to do this when using global script tags.</p>
  168. <h3 id="promise">Promise</h3>
  169. <p>Vuex requires <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises" target="_blank">Promise</a>. If your supporting browsers do not implement Promise (e.g. IE), you can use a polyfill library, such as <a href="https://github.com/stefanpenner/es6-promise" target="_blank">es6-promise</a>.</p>
  170. <p>You can include it via CDN:</p>
  171. <pre class="language-"><code class="lang-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.auto.js<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">&gt;</span></span>
  172. </code></pre>
  173. <p>Then <code>window.Promise</code> will be available automatically.</p>
  174. <p>If you prefer using a package manager such as NPM or Yarn, install it with the following commands:</p>
  175. <pre class="language-"><code class="lang-bash"><span class="token function">npm</span> <span class="token function">install</span> es6-promise --save <span class="token comment" spellcheck="true"># NPM</span>
  176. yarn add es6-promise <span class="token comment" spellcheck="true"># Yarn</span>
  177. </code></pre>
  178. <p>Furthermore, add the below line into anywhere in your code before using Vuex:</p>
  179. <pre class="language-"><code class="lang-js"><span class="token keyword">import</span> <span class="token string">&apos;es6-promise/auto&apos;</span>
  180. </code></pre>
  181. <h3 id="dev-build">Dev Build</h3>
  182. <p>You will have to clone directly from GitHub and build <code>vuex</code> yourself if
  183. you want to use the latest dev build.</p>
  184. <pre class="language-"><code class="lang-bash"><span class="token function">git</span> clone https://github.com/vuejs/vuex.git node_modules/vuex
  185. <span class="token function">cd</span> node_modules/vuex
  186. <span class="token function">npm</span> <span class="token function">install</span>
  187. <span class="token function">npm</span> run build
  188. </code></pre>
  189. </section>
  190. </div>
  191. <div class="search-results">
  192. <div class="has-results">
  193. <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
  194. <ul class="search-results-list"></ul>
  195. </div>
  196. <div class="no-results">
  197. <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. </div>
  203. <script src="//m.servedby-buysellads.com/monetization.js" type="text/javascript"></script>
  204. <div class="bsa-cpc"></div>
  205. <script>
  206. (function(){
  207. if(typeof _bsa !== 'undefined' && _bsa) {
  208. _bsa.init('default', 'CKYD62QM', 'placement:vuejsorg', {
  209. target: '.bsa-cpc',
  210. align: 'horizontal',
  211. disable_css: 'true'
  212. });
  213. }
  214. })();
  215. </script>
  216. </div>
  217. <a href="intro.html" class="navigation navigation-next navigation-unique" aria-label="Next page: What is Vuex?">
  218. <i class="fa fa-angle-right"></i>
  219. </a>
  220. </div>
  221. <script>
  222. var gitbook = gitbook || [];
  223. gitbook.push(function() {
  224. gitbook.page.hasChanged({"page":{"title":"Installation","level":"1.3","depth":1,"next":{"title":"What is Vuex?","level":"1.4","depth":1,"path":"intro.md","ref":"intro.md","articles":[]},"previous":{"title":"Release Notes","level":"1.2","depth":1,"url":"https://github.com/vuejs/vuex/releases","ref":"https://github.com/vuejs/vuex/releases","articles":[]},"dir":"ltr"},"config":{"plugins":["edit-link","prism","-highlight","github","-highlight","github"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"edit-link":{"label":"Edit This Page","base":"https://github.com/vuejs/vuex/tree/dev/docs"},"github":{"url":"https://github.com/vuejs/vuex/"},"prism":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":false,"twitter":false,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-vuejs":{},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Vuex","language":"en","links":{"sharing":{"facebook":false,"twitter":false}},"gitbook":"2.x.x"},"file":{"path":"installation.md","mtime":"2018-04-20T00:44:03.851Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2018-04-20T00:47:55.633Z"},"basePath":".","book":{"language":"en"}});
  225. });
  226. </script>
  227. </div>
  228. <script src="../gitbook/gitbook.js"></script>
  229. <script src="../gitbook/theme.js"></script>
  230. <script src="../gitbook/gitbook-plugin-edit-link/plugin.js"></script>
  231. <script src="../gitbook/gitbook-plugin-github/plugin.js"></script>
  232. <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
  233. <script src="../gitbook/gitbook-plugin-search/search.js"></script>
  234. <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
  235. <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
  236. <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
  237. </body>
  238. </html>