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