I have an input component using new defineModel()
<template>
<textarea
v-model="model"
required
/>
</template>
<script setup>
import { defineModel } from 'vue'
const model = defineModel()
</script>
then in paren component:
<article-comment-input v-model="msg"></article-comment-input>
const msg = ref('')
I also have a add a comment function:
async function addComments() {
const response = await commentsStore.addComment(msg.value, id)
msg.value = ''
if (response.status !== 200) {
makeAToast('Something went wrong', 'warning')
}
makeAToast('Added', 'success')
}
and the problem is that
msg.value = ''
doesnt reset the value of input after submitting comment. Why it doesnt reset- two way data binding doesnt work using model?