Replies: 1 comment 1 reply
-
I don't think this is a good idea because the events are written next to the element while being attached to something else. |
Beta Was this translation helpful? Give feedback.
1 reply
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.
-
What if there was a modifier to attach an event on
window
instead of its target when it is mounted, and removes it when unmounted?For example, if we call it
window
:What could it be useful for?
online
/offline
, history, gamepads.keydown
.click
for a "click outside" implementation.What are the alternatives?
Some of the example I gave would probably be better handled with custom directives.
Directives are less flexible, though. Consider the global shortcut example.
We could create a
v-shortcut
directive for that, and it could even parse the key from a modifier:v-shortcut.enter="..."
.ctrl.enter.exact
, we would need to re-implement that ourselves.v-shortcut.enter="() => submit(42)"
instead of@keydown.window.enter="submit(42)"
.v-shortcut
on the same element.Worth it or not?
Beta Was this translation helpful? Give feedback.
All reactions