how can I pass the v-model value from parent component to child's child component?
Parent component
<ChildElement v-model="name" />
<script>
import { ref } from "vue";
export default {
setup() {
const name = ref('Nagisa')
}
};
</script>
Child component
<AnotherChildComponent :value="value"/>
<script>
export default {
props: {
value: {
type: String,
default: ""
}
},
emits: ['update:modelValue']
};
</script>
AnotherChild component
<input :value="modelValue" @input="$emit('update:modelValue', $event.target.value)" />
<script>
export default {
props: {
modelValue: {
type: String,
default: ""
}
},
emits: ['update:modelValue'],
setup() {
}
};
</script>
This works when I want to update parent component name value from AnotherChild component, however the default name value ('Nagisa') will not render in AnotherChild component just stays empty string in input.
Vuex is not option, I want to directly pass from parent component. Thank you for your help.