I want to display firstname and lastname through Introduction.vue. In InformationField.vue i am declaring the props. and calling them in Introduction.vue by v-model:propsname ="form.introduction.propsname" . i am getting error inside <InformationField v-model .
Introduction.vue
<template>
<form>
<InformationField
v-model:firstname="form.introduction.firstname"
v-model:lastname="form.introduction.lastname"
/>
</form>
</template>
<script>
import InformationField from './InformationField.vue';
export default {
components: {
InformationField,
},
setup(){
const form = ref({
introduction:{
firstname: '',
lastname: '',
}
})
}
};
</script>
InformationField.vue
<template>
<div>
<label>
Firstname
<input
type="text"
@input="$emit('update:firstname', $event.target.value)"
:value="firstname"
ref="firstnameRef"
placeholder="firstname"
/>
</label>
<label>
Lastname
<input
type="text"
@input="$emit('update:lastname', $event.target.value)"
:value="lastname"
placeholder="lastname"
/>
</label>
</div>
</template>
<script>
export default {
props: {
firstname: {
type: String,
default: "",
},
lastname: {
type: String,
default: "",
}
},
};
</script>
v-model="form.introduction"
in case it acts as form model – Harsh