Last active
June 2, 2019 18:22
-
-
Save mysteriousHerb/1a966e105332e25565c1c49be529bb04 to your computer and use it in GitHub Desktop.
todo_comp template part
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
<template> | |
<div id="todos-vue"> | |
<div> | |
<label>New task:</label> | |
<!-- use v-model for 2-way binding, call method when user press enter @keyup.enter--> | |
<input id="new_todo" v-model="new_todo" placeholder="edit me" @keyup.enter="add_todo()"> | |
<button @click="add_todo()">Add</button> | |
</div> | |
<div> | |
<div v-for="(todo, index) in todos" :key="todo.id"> | |
<label>{{index}}.</label> | |
<!-- we also want to be able to directly update the existing todo, this is handled by v-model, but our database needs to be handled differently--> | |
<input v-model="todo.content" :disabled="todo.done" @keyup.enter="update_todo(todo)"> | |
<!-- when click the checkbox, the input becomes disabled --> | |
<input type="checkbox" v-model="todo.done"> | |
<button @click="remove_todo(index)">Delete</button> | |
</div> | |
</div> | |
</div> | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment