Add support for @mounted="mounted"
to be @mounted
if the function mounted
is defined on the component
#80
gingerchew
started this conversation in
Ideas
Replies: 1 comment
-
I've been fiddling with this and I've hit a small road-block. Adding the below code here: if (!exp && ctx.scope[arg]) handler = get(`function ${get(arg)}`); Then modifying the app on the <script type="module">
import { createApp } from '../src';
createApp({
// unnamed event handler
click() {
alert('clicked');
},
}).mount('#app');
</script> And it works! 🎉 The caveat is the example with the I added the guard: if (!exp && ctx.scope[arg] && !modifiers?.prevent) handler = get(`function ${get(arg)}`); Downside is now all |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
As I've been using petite-vue, I find myself writing events like this a lot:
Since the names of the functions don't matter much at this level, it is fine for them to be named after the event. Then I remembered
EventListener.handleEvent
. I first found out about it when reading about the quirkyness ofthis
in event listeners in this article by desandro.With
handleEvent
you can do stuff like this:It's that last line of the
eventHandler.handleEvent
function that I am hoping to emulateThat would mean that using this component:
The event directives on this HTML
Will work the same as on this HTML
I think this would be useful for organizing and also be useful for shorthand. What do others think though?
Beta Was this translation helpful? Give feedback.
All reactions