I am working with a parent form component and a child component, both located in separate files. I am using the Quasar Framework components. How can I pass data from the parent to the child component using v-model?
Parent Component
<template>
<q-input
label="Name *"
lazy-rules
:rules="[val => (val && val.length > 0) || 'Please enter your name']"
v-model="name"
/>
</template>
<script>
export default {
name: "Name",
data() {
return {
name: "Max"
};
}
};
</script>
Child Component
<template>
<div class="q-pa-md" style="max-width: 500px">
<q-form @reset="onReset" class="q-gutter-md">
<Nome> </Nome>
<div>
<q-btn label="Reset" type="reset" color="red" flat class="q-ml-sm" />
</div>
</q-form>
</div>
</template>
<script>
import Name from "components/Name.vue";
export default {
components: { Name },
onReset() {
this.name = null;
}
};
</script>
How does the onReset() function work in this setup?
This content has been automatically translated.