Vue 2.x version Parent-child component bidirectional binding event __vue bidirectional binding

Source: Internet
Author: User

Before the interview time technology very natural to ask you know Vue have any characteristics, at that time did not understand Vue, Just to vue1.0 some knowledge to learn a little, and then casually said Vue can two-way binding data, now think really embarrassed Ah, vue2.0 has removed two-way binding, need to do it yourself to achieve. The following text:
Vue 2.x compared to Vue 1.x, there is a relatively large change is the removal of the components of the props two-way binding function.
The props twoway and. Sync binding modifiers are used in vue1.x to achieve props bidirectional binding functionality, but this functionality is completely discarded in vue2.x, which needs to be implemented if bidirectional binding is required.
In Vue2, the props data flow of a component is one-way, which is passed through the component's Dom property outside the component to the component, the component can only passively receive the data from the component, and within the component, the props data from the outer layer cannot be modified.
For example, two-way binding parent-child component data in Vue2, specific reference to the previous subassembly –> the parent component of the bus. $emit () method, the parent component can pass props to change the state on the child component Dom, while in the subassembly you want to change the state without directly modifying the parent component's data. Can only pass the changed state to the parent component, in the parent component by the parent component to receive the state of the child component to implement data changes, so that the parent-child component state two-way binding

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.