Passing functions as props vs Emitting events #9577
-
Hi there, I know that in the documentation there are no examples that promote the approach of passing methods/functions as props but to be honest it does not look that bad for some cases. After searching through old discussions this is the only one ( #9066 )that I managed to find. I would like to challenge that topic and have some more concrete answers from people that are aware of the Vue framework in a more deep level. Is it an anti-pattern to do something like that? Thanks a lot in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I prefer to design it this way. On components, Vue prefers to distinguish props from events. It is not like react that passes all properties or events to components through props. Differentiating props and events is beneficial to component maintenance, but users must make a clear distinction when writing components. This is a design choice and trade-off. |
Beta Was this translation helpful? Give feedback.
I prefer to design it this way. On components, Vue prefers to distinguish props from events. It is not like react that passes all properties or events to components through props. Differentiating props and events is beneficial to component maintenance, but users must make a clear distinction when writing components. This is a design choice and trade-off.