I encountered an error message: Uncaught TypeError: 'set' on proxy: trap returned falsish for property 'NewTodo'
This error occurs when attempting to reset the input text value within a child component (FormAddTodo.vue).
App.vue:
export default {
data(){
return{
todos: [],
newTodo: ""
}
},
components: {
Todos,
FormAddTodo
}
}
</script>
<template>
<div class="container mx-auto">
<Todos :todos="todos" />
<div class="py-8"></div>
<FormAddTodo :NewTodo="newTodo" :Todos="todos" />
</div>
</template>
FormAddTodo.vue:
<template>
<div class="formAddTodo">
<form @submit.prevent="handleAddTodo" class="addTodo">
<input type="text" class="" placeholder="type new todo here..." v-model="NewTodo">
</form>
</div>
</template>
<script>
export default {
props: ['NewTodo', 'Todos'],
methods: {
handleAddTodo(){
const colors = ["cyan", "blue", "indigo", "pink"]
const todo = {
id: Math.random(),
content: this.NewTodo,
color: colors[Math.floor(Math.random() * ((colors.length-1) - 0 + 1) + 0)]
}
this.Todos.push(todo)
this.NewTodo = '' // this line triggers the error
}
}
}
</script>