Hey there, I am currently learning vuejs and facing an issue with setting an object value to a vue data property.
data: () => ({
newTodo: "",
todoObj: { title: newTodo, undo: false },
toDoList: [
{ title: "Study", undo: false },
{ title: "Work", undo: false },
{ title: "Gaming", undo:false }
],
}),
methods: {
addNewToList() {
this.toDoList.push(this.todoObj);
this.newTodo = "";
},
},
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.4/vue.js"></script>
I am trying to bind newTodo to the input and then add the object to an array. However, newTodo is showing as undefined. Please suggest if you have a better approach for achieving this functionality.
Thank you in advance!