Installing Vuex
There are two main methods of using Vuex, depending on the type of Vue application you're building. If you are not using the CLI to scaffold out an application and simply added Vue via a script tag, you can include Vuex the same way. Assuming you've downloaded both Vue and Vuex to a folder named js
, you would load them both like so:
<script src="js/vue.js"></script> <script src="js/vuex.js"></script>
You can also load both Vue and Vuex via Content Delivery Networks (CDNs):
<script src="https://unpkg.com/vue"></script> <script src="https://unpkg.com/vuex"></script>
Note
It is important that Vuex is loaded after Vue. Doing so makes Vuex available to your Vue code without any other configuration.
If you created an application using the CLI, remember first that the CLI itself will prompt you during creation if you want to add Vuex: