Home >Web Front-end >JS Tutorial >Using vuex under vue-cli (detailed tutorial)

Using vuex under vue-cli (detailed tutorial)

亚连
亚连Original
2018-06-04 14:50:374438browse

This article mainly introduces the simple demo of vuex under vue-cli (implementing the operation of adding 1 and subtracting 1). This article introduces it to you in great detail with pictures and texts, and has reference value. Friends who need it can refer to it

1. After vue-cli builds the project, use npm to install vuex

 npm install vuex --save

2. Build the vuex directory in the project directory (I created a new one here store folder, with the store.js file newly created in it)


#3. In the entry file main.js in the vue project, it is the instantiated Vue Add the store object to the object

4. Configure and write the store.js file

5. Use vuex in the component Stored data

6. To achieve the effect

above I compiled it for everyone. I hope it will be helpful to everyone in the future.

Related articles:

What are the methods by which Vue can use CSS to replace scoped with modules?

How to use Vuex to implement the counter function

In-depth explanation of the basic principles of the webpack module

The above is the detailed content of Using vuex under vue-cli (detailed tutorial). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn