


How to implement data transfer, modification and update of parent-child components in Vue (detailed tutorial)
Jun 02, 2018 am 10:33 AMBelow I will share with you an article on the data transfer, modification and update methods of Vue parent-child components. It has a good reference value and I hope it will be helpful to everyone.
The data relationship between parent and child components, I will divide the situation into the following four types:
Parent component modifies child The data of the component, and updated in real time
The sub-component passes the data of the sub-component through $emit, this.$data refers to all the data in the data(return{...}) of the current component,
1 |
|
Then receive the data through the getinputdata method of the parent component
1 |
|
The data is the passed data. By modifying this data, the child component can be updated in real time through the parent component
1 2 3 4 5 6 7 |
|
Subcomponent modifies the data of the parent component
You cannot modify the data of the parent component in the subcomponent. You can only modify the data in the parent component through the $emit method above.
You can refer to the custom events on the vue official website: https://cn.vuejs.org/v2/guide/components.html#Custom events
The child component gets the parent component data, modified but not updated in real time
1. The child component transfers the data passed by the parent component through props, and then assigns the props value to the let or var declaration variable, and then uses this variable. .
1 2 3 4 |
|
2. The child component transfers the data passed by the parent component through props, and then assigns the props value to the variable in data(return{...}), and then uses this variable.
1 2 3 |
|
You can refer to the custom events on the vue official website: https://cn.vuejs.org/v2/guide/components.html#One-way data flow
Get the parent component The data of the child component is modified but not updated in real time.
The method here is the same as the method of 'The child component obtains the data of the parent component and is modified but not updated in real time'. Among them, only the method of passing value is the difference. The child component passes the value to the parent component through $emit.
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
Vue.js custom event form input component method
vue.js moves the array position and updates it at the same time View method
vue.js or js method to implement Chinese A-Z sorting
The above is the detailed content of How to implement data transfer, modification and update of parent-child components in Vue (detailed tutorial). For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to change the personal name in the group on DingTalk_How to modify the personal name in the group on DingTalk

Use ddrescue to recover data on Linux

Open source! Beyond ZoeDepth! DepthFM: Fast and accurate monocular depth estimation!

The vitality of super intelligence awakens! But with the arrival of self-updating AI, mothers no longer have to worry about data bottlenecks

Google is ecstatic: JAX performance surpasses Pytorch and TensorFlow! It may become the fastest choice for GPU inference training

Can Douyin Blue V change its name? What are the steps to change the name of corporate Douyin Blue V account?

Slow Cellular Data Internet Speeds on iPhone: Fixes

The U.S. Air Force showcases its first AI fighter jet with high profile! The minister personally conducted the test drive without interfering during the whole process, and 100,000 lines of code were tested for 21 times.
