Advertisement
soden

Untitled

Mar 2nd, 2024
774
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.63 KB | Source Code | 0 0
  1. <template>
  2.   <div>
  3.     <h1>Daftar Tugas</h1>
  4.     <input type="text" v-model="newTask" @keyup.enter="addTask">
  5.     <ul>
  6.       <li v-for="(task, index) in tasks" :key="index">
  7.         {{ task }}
  8.         <button @click="removeTask(index)">Hapus</button>
  9.       </li>
  10.     </ul>
  11.   </div>
  12. </template>
  13.  
  14. <script>
  15. export default {
  16.   data() {
  17.     return {
  18.       tasks: [],
  19.       newTask: ''
  20.     };
  21.   },
  22.   methods: {
  23.     addTask() {
  24.       if (this.newTask !== '') {
  25.         this.tasks.push(this.newTask);
  26.         this.newTask = '';
  27.       }
  28.     },
  29.     removeTask(index) {
  30.       this.tasks.splice(index, 1);
  31.     }
  32.   }
  33. };
  34. </script>
Tags: laravel vue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement