Home > other >  Whether the custom event from grandson components directly passed to grandpa?
Whether the custom event from grandson components directly passed to grandpa?

Time:12-30


Whether the custom event from grandson components directly passed to grandpa? If it is, to help explain the reason, thank

CodePudding user response:

Understand, thank you very much, thank you very much

CodePudding user response:

Yes, you can't, the custom event can only be passed on from component to its parent components, will not continue to pass, in other words, the custom event without bubble mechanism, as to why, can only say that the Vue event mechanism are designed in this way,
If you ask, the purpose of this design is simply to simplify the data flow between the components of transmission, a one-way downward data flow is in conformity with the intuition, and easy to understand, but sometimes the state produced in child elements and consumption needs by the parent element, it's the reverse state transfer, in a one-way downward to the general principle of data stream, the reverse transfer should not have a lot of (or big principle will not stand), the scope and should not be very big, otherwise it will increase the complexity of the state), so the custom event just passed up a layer of the default behavior is taken for granted, in addition, the event itself is not restricted to consumers, the structure of a custom event and not unified, if there is a bubble mechanism, among the one thousand who happens to consumption the same characteristics (event name), it would be wrong,

CodePudding user response:

Can, with v - on="$listeners", this is to increase the function of vue2.4
  • Related