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/component-custom-events.md
+11-10Lines changed: 11 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,12 +90,11 @@ By default, `v-model` on a component uses `modelValue` as the prop and `update:m
90
90
In this case, child component will expect a `title` prop and emits `update:title` event to sync:
91
91
92
92
```js
93
-
constapp=Vue.createApp({})
94
-
95
93
app.component('my-component', {
96
94
props: {
97
95
title:String
98
96
},
97
+
emits: ['update:title'],
99
98
template:`
100
99
<input
101
100
type="text"
@@ -123,13 +122,12 @@ Each v-model will sync to a different prop, without the need for extra options i
123
122
```
124
123
125
124
```js
126
-
constapp=Vue.createApp({})
127
-
128
125
app.component('user-name', {
129
126
props: {
130
127
firstName:String,
131
128
lastName:String
132
129
},
130
+
emits: ['update:firstName', 'update:lastName'],
133
131
template:`
134
132
<input
135
133
type="text"
@@ -157,7 +155,7 @@ Modifiers added to a component `v-model` will be provided to the component via t
157
155
Notice that when the component's `created` lifecycle hook triggers, the `modelModifiers` prop contains `capitalize` and its value is `true` - due to it being set on the `v-model` binding `v-model.capitalize="bar"`.
0 commit comments