From ba6e4b8f52c91f254ffb27c6607ab523c7666dd3 Mon Sep 17 00:00:00 2001 From: Steve Bauman Date: Wed, 9 Oct 2024 11:11:26 -0400 Subject: [PATCH 1/2] Add docs about capturing event listeners in child components --- src/api/options-state.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/api/options-state.md b/src/api/options-state.md index b975a50f54..d7072e2f5e 100644 --- a/src/api/options-state.md +++ b/src/api/options-state.md @@ -433,6 +433,21 @@ Declare the custom events emitted by the component. } ``` +Listeners on events may be captured in components by defining them as properties with the naming scheme of `on{Event}`: + +> If an event contains a colon, use the naming scheme `on{Event}:{event}`. + +```js +export default { + props: { + onCheck: Function, + 'onClick:export': Function, + }, + + emits: ['check', 'click:export'], +} +``` + - **See also** - [Guide - Fallthrough Attributes](/guide/components/attrs) - [Guide - Typing Component Emits](/guide/typescript/options-api#typing-component-emits) From 636f4b3bed2a488ab4b65881657a374bba340469 Mon Sep 17 00:00:00 2001 From: Steve Bauman Date: Wed, 9 Oct 2024 11:13:01 -0400 Subject: [PATCH 2/2] Spacing --- src/api/options-state.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/api/options-state.md b/src/api/options-state.md index d7072e2f5e..7a1361d130 100644 --- a/src/api/options-state.md +++ b/src/api/options-state.md @@ -433,20 +433,20 @@ Declare the custom events emitted by the component. } ``` -Listeners on events may be captured in components by defining them as properties with the naming scheme of `on{Event}`: - -> If an event contains a colon, use the naming scheme `on{Event}:{event}`. - -```js -export default { - props: { - onCheck: Function, - 'onClick:export': Function, - }, - - emits: ['check', 'click:export'], -} -``` + Listeners on events may be captured in components by defining them as properties with the naming scheme of `on{Event}`: + + > If an event contains a colon, use the naming scheme `on{Event}:{event}`. + + ```js + export default { + props: { + onCheck: Function, + 'onClick:export': Function, + }, + + emits: ['check', 'click:export'], + } + ``` - **See also** - [Guide - Fallthrough Attributes](/guide/components/attrs)