Skip to content

Instantly share code, notes, and snippets.

@juhahinkula
Last active June 19, 2019 08:45
Show Gist options
  • Save juhahinkula/bb72447a7fd53ac43a134bd2cd43967f to your computer and use it in GitHub Desktop.
Save juhahinkula/bb72447a7fd53ac43a134bd2cd43967f to your computer and use it in GitHub Desktop.
<template>
<div>
<input type="text" placeholder="New todo" v-model="todo" />
<button v-on:click="add">Add</button><br />
<table>
<tbody>
<tr v-for="(todo, index) in todos" v-bind:key="index"><td>{{todo}}</td></tr>
</tbody>
</table>
</div>
</template>
<script>
export default {
name: 'TodoList',
data() {
return {
todos: [],
description: ''
}
},
methods: {
add: function() {
this.todos.push(this.description);
this.description = ''
}
},
}
</script>
<style>
table {
margin-left:auto;
margin-right:auto;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment