Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <template>
- <div>
- <h1>Daftar Tugas</h1>
- <input type="text" v-model="newTask" @keyup.enter="addTask">
- <ul>
- <li v-for="(task, index) in tasks" :key="index">
- {{ task }}
- <button @click="removeTask(index)">Hapus</button>
- </li>
- </ul>
- </div>
- </template>
- <script>
- export default {
- data() {
- return {
- tasks: [],
- newTask: ''
- };
- },
- methods: {
- addTask() {
- if (this.newTask !== '') {
- this.tasks.push(this.newTask);
- this.newTask = '';
- }
- },
- removeTask(index) {
- this.tasks.splice(index, 1);
- }
- }
- };
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement