Created
May 29, 2020 09:31
-
-
Save TheBojda/dd88a7f689429261dffd746823337249 to your computer and use it in GitHub Desktop.
Simple Vue.js TODO app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Vue.js TODO Example</title> | |
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> | |
</head> | |
<body> | |
<div id="app"> | |
<table> | |
<tr v-for="(todo, idx) in todos"> | |
<td>{{todo}}</td> | |
<td><button @click="removeItem(idx)">Done</button></td> | |
</tr> | |
<tr> | |
<td><input type="text" placeholder="TODO item" v-model="todoText" /></td> | |
<td><button @click="addItem">Add</button></td> | |
</tr> | |
</table> | |
</div> | |
<script> | |
new Vue({ | |
el: '#app', | |
data: { | |
todoText: '', | |
todos: [] | |
}, | |
methods: { | |
addItem() { | |
this.todos.push(this.todoText); | |
this.todoText = ''; | |
}, | |
removeItem(idx) { | |
this.todos.splice(idx, 1); | |
} | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment