Vuejs + Vuex

Source: Internet
Author: User

Vuejs data is two-way bound, and the data is only in the parent component, if the data common to each component is to be managed through a container.

Vuex is a good choice,

Today, I looked at the next Vuex tutorial:

Summary of the problems encountered: VUE-CLI a project

Import when the error was found: node version is too low, the upgrade version is good.

Import {Mapstate,mapactions,mapgetters,map} from "Vuex";//note curly braces. Https://github.com/lin-xin/notepad/This example is very good. Combined with the concept of modules Vuex core

Five core attributes:

    • State
    • Getters
    • Mutations
    • Actions
    • Modules
Four auxiliary functions
    • Mapstate
    • Mapgetters
    • Mapactions
    • Mapmutations
Run the process
    • State is the data storage warehouse, can be divided into Submodule module, each module has a self-supporting contextual object context, has its own state, mutation, action, getters, modules and so on system

    • Getters is primarily used to obtain data from the state, with the advantage of being versatile

    • Mutations is used to update the data in the state repository, the only change data place, real-time synchronization modification, not asynchronous, not asynchronous, not asynchronous

    • Actions mainly supplement the ability to update the state warehouse data asynchronously, and the internal still triggers the mutation to implement

    • Modules to manage the Data warehouse in order to partition the state module

Note: getters,mutations,actions is mounted directly on the instance store of Vuex, either in the module block, only the state maintains a chained namespace, for example, Store.state.module[key] And so on, so if the state of the submodule, directly with the auxiliary function mapstate is not obtained.

Vuejs + Vuex

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.