Is passing parent method as props with @
correct approach?
#9797
Replies: 2 comments 4 replies
-
|
Beta Was this translation helpful? Give feedback.
-
@Shyam-Chen Maybe I just should understand |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm working on project and see below code that parent component is passing the method down to the child component as props using
@
like below.Codes
What I initially thought is parent component(App.vue) is listening event named "foo" that is emited in child component.(something like
emit("foo")
)However, I never see any "emit" inside child component, instead I see that child component takes
onFoo
as props from parent.I'm kinda confuse because I thought we should use v-bind when passing down props to child component(
:on-foo
), but it seems both scenarios(:on-foo
or@foo
) work actually.(I mean both shows "click event called" on console)example
@foo
Can anyone explain why
@foo
is doing the same behavior as:on-foo
and is@foo
approach is correct one to passing down method as props?Also appreciate if you could share the link of doc where explain about it.
Thanks in advance. 🙏
Beta Was this translation helpful? Give feedback.
All reactions