The pit that Vue has encountered (the parent component passes the value to the input box component, and then the subassembly uses the data that is passed in to bind the data and solve the problem)

Source: Internet
Author: User
Tags bind

A major feature of Vue.js is the ability to implement many reusable components.
When I was doing the project, I encapsulated an input box component, and then all of the same styles on the page were called with this component, and just at first thought it was simple to implement, as a Vue just learned, not just to write a single component, then each page input problem, But actually when I was in the process of passing the value of the problem, because in our pass-through, Vue has always followed the data coupling, not to change the data between the two, Vue also provided an error, but in the parent component passed the value to the child component, and the child component of this property V-model bound, When we change the value on the input box, we change the value of the parent component. The solution is as follows
Parent component

Sub-component


Key content
The input component maintains private data, assigns values through computed, and watch changes notifies the parent component via $emit

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.