-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Generic v-on syntax without argument #4703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Really like this!! |
Hmm, I feel this introduces way too much syntax variations for the same purpose, and the only benefits is that it becomes a bit more flexible to deal with programmatic event handling in templates. However, imo when you need this level of flexibility for attaching event handlers, it'd be better off to just use a render function rather than adding new syntax to the templates. |
We could only have the |
It can be done in render function as: render (h) {
return h('modal', this.$vnode.data, [
h('input', ...)
])
}
|
And in JSX I would do |
Yes. |
This special syntax is somewhat inspired by the
v-bind:class
.Let's take this component as an example:
These call the
handleEvents
method when any event is emitted, with the following signature:function (eventType, ...args)
.These call both
handleEvents
andhandleEvents2
methods.These call the
handleAction
method when theaction
event is emitted, with the usual signature:function (...args)
.You can mix everything!
Or store it all in a reactive property!
With the $props, it could allow making specialized components out of generic ones much easier:
In this example, we expose the same interface as the
Modal
component (props and events), while making it more specialized with news props/events and a pre-made template.If you want, take a look at this working proof of concept.
The text was updated successfully, but these errors were encountered: