8000 add note about custom event methods not being aliases for EventTarget… · ywwhack/vuejs.org@1476de3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1476de3

Browse files
committed
add note about custom event methods not being aliases for EventTarget API
1 parent 6ae8a59 commit 1476de3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/guide/components.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,15 +419,17 @@ When a prop validation fails, Vue will produce a console warning (if using the d
419419

420420
## Custom Events
421421

422-
We have learned that the parent can pass data down to the child using props, but how do we communicate back to the parent when something happens? This is where custom events come in.
422+
We have learned that the parent can pass data down to the child using props, but how do we communicate back to the parent when something happens? This is where Vue's custom event system comes in.
423423

424424
### Using `v-on` with Custom Events
425425

426-
Every Vue instance implements the [Events interface](/api/#Instance-Methods-Events), which means it can:
426+
Every Vue instance implements an [events interface](/api/#Instance-Methods-Events), which means it can:
427427

428428
- Listen to an event using `$on(eventName)`
429429
- Trigger an event using `$emit(eventName)`
430430

431+
<p class="tip">Note that Vue's event system is separate from the browser's [EventTarget API](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget). Though they work similarly, `$on` and `$emit` are __not__ aliases for `addEventListener` and `dispatchEvent`.</p>
432+
431433
In addition, a parent component can listen to the events emitted from a child component using `v-on` directly in the template where the child component is used.
432434

433435
Here's an example:

0 commit comments

Comments
 (0)
0