1. Passing values between child components and parent components
The child component is passed to the parent component: in the form of events
Value transfer between subcomponents of the same file
Use the parent component as an intermediary to pass the unidirectional flow
Passing values between sub-components of different files (such as different components in the component, it is not convenient to write logic code in the component) [Bus]
You can use Bus to pass the value (Bus is a new Vue instance object, mounted on the global Vue original prototype object, so that you can listen to the change of the Bus data state at the root component to send and receive values)
2. Vuex state management
Work flow of Vuex
Vuex structure
------ State attribute is equivalent to (data attribute)
Defined in state.js, introduced in index.js
The first way to get the value defined in the state in the component
The second way to define the value in the state in the component (via mapState)
Can open the namespace for the module (easy access)
1.
2.
------ getters attribute is equivalent to (computed attribute)
The definition format of the getters module is as follows
The first way to get the value defined in the getters in the component
The second way to get the value defined in the getter in the component (using mapGetters)
2.
3.