You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/guide/components/events.md
+15-3Lines changed: 15 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ if (typeof window !== 'undefined') {
17
17
}
18
18
}
19
19
</script>
20
+
20
21
# Component Events {#component-events}
21
22
22
23
> This page assumes you've already read the [Components Basics](/guide/essentials/component-basics). Read that first if you are new to components.
@@ -176,14 +177,14 @@ export default {
176
177
177
178
</div>
178
179
179
-
The `emits` option and `defineEmits()` macro also support an object syntax, which allows us to perform runtime validation of the payload of the emitted events:
180
+
The `emits` option and `defineEmits()` macro also support an object syntax. If using TypeScript you can type arguments, which allows us to perform runtime validation of the payload of the emitted events:
You may also declare and pass `events` as `props`, by prefixing the capitalized event name with `on`
295
+
Using `props.onEvent` has a different behaviour than using `emit('event')`, as the former will pass only handle the property based listener (either `@event` or `:on-event`)
296
+
297
+
:::warning
298
+
If both `:onEvent` and `@event` are passed `props.onEvent` might be an array of `functions` instead of `function`, this behavior is not stable and might change in the future.
299
+
:::
300
+
301
+
Because of this, it is recommended to use `emit('event')` instead of `props.onEvent` when emitting events.
0 commit comments