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/style-guide/rules-essential.md
+48-18Lines changed: 48 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -107,51 +107,81 @@ Treat emitted events as part of a component's public contract, and declare them
107
107
Explicit [event declarations](/guide/components/events) document how a component communicates outward and make parent-child interactions easier to follow.
108
108
:::
109
109
110
+
In standard `setup()` usage, declare events with the [`emits`](/guide/components/events#declaring-emitted-events) option. In [`<script setup>`](/api/sfc-script-setup#defineprops-defineemits), declare them with `defineEmits()`.
111
+
112
+
Use the object syntax when event payloads need validation, and an array of event names when they do not.
113
+
114
+
In TypeScript, prefer a typed `defineEmits()` declaration so the event contract is checked by the type system as well as documented in the component. In Vue 3.3+, the named tuple syntax is usually the more succinct form.
- An array of event names is acceptable when payload validation would add no real value.
152
-
- In TypeScript, prefer a typed `defineEmits()` declaration so the event contract is checked by the type system as well as documented in the component.
153
-
- If runtime payload validation is also useful, use the object syntax.
154
-
155
185
## Keep parent-child data flow explicit {#keep-parent-child-data-flow-explicit}
156
186
157
187
Pass data down with props, and communicate requested changes back up with emitted events.
0 commit comments