File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -247,7 +247,7 @@ Next let's look at a minimal example of a 'TodoEditor' component which is a chil
247
247
248
248
```vue
249
249
<template>
250
- <form @submit.prevent=" $emit ( ' save ' ) " >
250
+ <form @submit.prevent=" handleSubmit " >
251
251
<input type=" checkbox" v-model=" item .isComplete " />
252
252
<input type=" text" v-model=" item .description " />
253
253
@@ -270,6 +270,19 @@ export default {
270
270
type: Object,
271
271
required: true
272
272
}
273
+ },
274
+ setup(props, context) {
275
+ function handleSubmit() {
276
+ // This is a placeholder for checking form validity, (with Vuelidate, for example)
277
+ const isValid = true || false
278
+
279
+ if (formIsValid) {
280
+ context.emit('save')
281
+ } else {
282
+ // Show any form errors in the UI.
283
+ }
284
+ }
285
+ return { handleSubmit }
273
286
}
274
287
}
275
288
</script>
You can’t perform that action at this time.
0 commit comments