The difference between the methods and mounted

mounted: In this launch backend requests, back data, with the routing hook to do something (dom render complete assembly mounts to complete)

Some functions required in the event methods are generally defined trigger. Every time a trigger event, will perform the corresponding method.

If the method computed in the written method performance will be wasted. computed value must return to a page bound to get value,

Methods may be performed while only the logic code, there may be a return value, or may not.

1.methods:

Listen for the click event

methods:{

      clickFunction:function(){

      }

}

2.mounted:

Page initialization method

mounted(){ 

}

The execution order is sub-assemblies --- parent component

3.props:

Receive data from the parent element

props: {
   seller: {
        type: Object
    }
}

. 4 . $ Pass value to the parent component EMIT

 this.$emit('showCityName',data);
ShowCItyName parent component of the trigger event.

 

Guess you like

Origin www.cnblogs.com/dianzan/p/12402653.html