I am currently attempting to pass a ref in order to retrieve the value of the input (base-input component) upon submission. The two components are listed below. Despite having a console.log statement in handleSubmit, the email variable always appears as undefined.
Any assistance you can provide would be greatly appreciated.
Parent Component
<template>
<form @submit.prevent="handleSubmit">
<div class="flex flex-col mt-10">
<form-label forInput="email" label="Email Address" />
<base-input type="email" name="email" ref="email" />
</div>
</form>
</template>
<script>
import BaseInput from "../UI/BaseInput.vue";
export default {
components: {
BaseInput,
},
methods: {
handleSubmit() {
const email = this.$refs.email.value;
console.log(email);
},
},
};
</script>
Child Input Component
<template>
<input
:type="type"
:name="name"
:ref="name"
/>
</template>
<script>
export default {
props: ["type", "name"],
};
</script>