1. The parent component returns the callback function to the child component, passing the data as parameters in the child component to call
and
2. The emit data of the child component is given to the parent component. What"s the difference in using
in the parent component
I feel that all of them can be used in the first way. Why do we need emit as a sub-component?
at present, the only way I can think of is the first way. The child component can modify the method passed by the parent component, which doesn"t feel good
PS: finds another problem when the child component tries to modify the props, such as
this.props.callback = function () {alert ("overridden parent component method")}
, it is possible to overwrite
but if
var a = this.props.callback
a = function(){alert("")}
this can"t be changed. It"s strange. Why?
these two questions are very confusing. I am a novice at vue, and I am grateful for the advice of the Great God.