vue child page, pass values to parent page...

Child components pass values ​​to parent components through events...

Parent component method:

methods: {
            appendData: function (list) {
                console.log(list);
                for (var i = 0; i < list.length; i++) {
                    this.recruitArray.push(list[0]);
                }
            }
        },

Subassembly:

   sendData: function (list) {
                 /* Through the appendData method of the parent component, the parent component can get the list value to add the value!!! This event is best to be all lowercase.. Otherwise, there are various problems Appears... */ 
                this .$emit('appenddata' , list);
            }

Note.. The event name is best to be all lowercase... Otherwise, an error will occur.. The root page component cannot receive the value passed by the subcomponent, but the component in the root page component can get the value when calling the component.. ..

When calling a child component:

    <vue-pull-load :start-load="recruitStartLoad" 
                                           :fetch -url="'__MODULE__/shangquan/getShopRecruit?id='+shop.id" 
                                           @appenddata ="appendData"></vue-pull-load> $emit event name="event name in parent component.."

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326498230&siteId=291194637