Child components passing values to parent components

Source: Internet
Author: User

Child to Parent Value://Sub-component The essence of passing a value like a parent component is that the parent passes the method, and the child calls the method, passing the data as a parameter to the method
Parent Component: Goodsinfo.vue sub-component: Goodsinfo_numbox.vue
1.goodsinfo.vue operation: 1. Importing subcomponents import Numbox from "/component/goodsinfo_numbox.vue"
2.data registration; Components:{numbox}
3.<numbox @getcount = "Getselectcount" ></numbox>
4. Getselectedcount (count) {
Saves the selected value to data when the child component passes the selected quantity to the parent component
This.selectedcount = count;
Console.log ("The parent component gets a quantity value of:" + This.selectedcount);
}
5. Sub-component: Goodsinfo_numbox.vue operation: countchanged () {
Whenever the data in the text box is modified, the latest data is immediately passed to the parent component via the event call.
Console.log (this. $refs. Numbox.value);
The. $emit ("GetCount", parseint (this. $refs. Numbox.value));
}

JS for routing navigation
Tthis. $router. Push ("home/goodinfro/" +id)

Child components passing values to parent components

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.