Skip to content

Instantly share code, notes, and snippets.

@codemwnci
Created August 25, 2017 21:38
Show Gist options
  • Save codemwnci/4680a767c4d050819b338ca3493e30b5 to your computer and use it in GitHub Desktop.
Save codemwnci/4680a767c4d050819b338ca3493e30b5 to your computer and use it in GitHub Desktop.
Add a Todo / VueJS
<body>
<div id="app">
<input type="text" @keyup.enter="addTodo">
<ul>
<li v-for="todo in todos">
{{todo.text}}
</li>
</ul>
</div>
<script>
var app = new Vue({
el: '#app',
data: {
todos: []
},
methods: {
addTodo: function(event) {
axios.post("http://localhost:9000/todo/", event.srcElement.value).then(response => {
this.todos.push(response.data);
});
event.srcElement.value = "";
},
},
mounted() {
}
})
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment