Getting started with Vuex

Source: Internet
Author: User

Getting started with Vuex

1. What is Vuex?

Schools:Vuex IsVue.js State management mode for application development; it centrally stores and manages the status of all components of the application.

Understanding:The above four words are the key to our understanding. Status: What is status, we can generally understand it as data. Vue only cares about the view layer. How can we determine the view status? We know that it is data-driven. The State management here can be simply understood as data management. Centralized storage:VueOnly focus on the view, then we need a warehouse (StoreAnd all data is stored in a centralized manner, and views and data can be analyzed. Management: In addition to storage, you can also manage data, that is, computing and processing data. All component statuses: the components used share a warehouse (Store), That is, a project has only one data source (differentiation Modulemodules).

Summary:Vuex is a warehouse that provides unique management data sources in a project.

2. What is the purpose? Use Cases?

Scenario 1: processing multiple components depends on the same data. For example, two components, bar chart and bar chart, are both displaying the same data;

Scenario 2: the behavior of one component -- changing data -- affects the view of another component, that is, the data of Public dependency;

VuexRemove the public data of components and manage them in a public warehouse so that each component can be easily obtained (getter) Data, and easy to set data (setter).

3. Source Code Overview

This isVuexThe source code file contains a total of five parts,PluginsTwo injection files, core filesindex, Help Group documenthelper, Tool Fileutil.js

Let's take a look at the Index. js File export framework, which will be analyzed in detail later.

   export default {     Store,       install,     mapState,     mapMutations,     mapGetters,     mapActions           }

Subsequent analysisStoreRepository.

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.