Why does this work? (event-listner prop) #14107
Replies: 1 comment
-
|
The template attributes all get mapped down into VNode props (not to be confused with component props). The VNode props are the properties passed into the For There are a few other places in the docs that allude to this, but that's probably the most explicit. You can also see this using the Vue Playground to inspect the compiled output for a template with a listener. Inside the child component, any VNode prop can be turned into a component prop by listing it in Another case where this is relevant is fallthrough attributes. VNode props that aren't listed in either While it isn't documentation, also note the warning message in this example: This warning acknowledges that an emitted event can either be declared in the usual way (using |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi I am confused over here,
I made a modal component that I can feed with function props. These can even be validated using runtime validation (as stated here). It feels like an anti-pattern as soon as you use a prop name called "onXxx" in this example, I used
onCallback. In this example I made the prop a promise so I can showcase the ability to run async calls like this. You can even use the prop to add a conditional in thetemplate-tag or in thescript-tagCallbackComponent.vueThe fun actually starts when you use this component.
App.vueAs you can see, I can use the event listener syntax on the prop! And this won't give me any errors… in fact, it works like a charm. Why? I can also add
@callback-calledand@callback-failedlisteners to react to the other emits.Can anyone send me a piece of the docs or explain this? I haven't found any references to this behavior.
Beta Was this translation helpful? Give feedback.
All reactions