Advertisement
Guest User

zanko

a guest
Jan 17th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7.  
  8. <title>Document</title>
  9. <style>
  10. .is-loading{background:red; }
  11. </style>
  12.  
  13. </head>
  14. <body>
  15. <div id="root">
  16. <h1>All tasks</h1>
  17.  
  18. <ul v-for="task in tasks" :id ="task.id">
  19. <li v-text="task.description"></li>
  20. <button :id="task.id" @click='finish($event, task.id)'>Done</button>
  21. <button :id="task.id" @click='unfinish($event, task.id)'>Not Done</button>
  22. </ul>
  23. <h1>Complete tasks</h1>
  24.  
  25. <ul>
  26. <li v-for="task in completeTasks" v-text="task.description">
  27.  
  28. </li>
  29. </ul>
  30.  
  31. <h1>Incomplete tasks</h1>
  32.  
  33. <ul>
  34. <li v-for="task in incomleteTasks" v-text="task.description">
  35.  
  36. </li>
  37. </ul>
  38.  
  39.  
  40.  
  41. </div>
  42.  
  43.  
  44. <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  45.  
  46.  
  47. <script>
  48.  
  49. new Vue ({
  50. el:'#root',
  51. data:{
  52.  
  53. tasks:[
  54. {id:0 ,description: 'Go to the store', completed: true},
  55. {id:1 ,description: 'Napraj ova', completed: false},
  56. {id:2 ,description: 'Napraj ona', completed: false},
  57. {id:3 ,description: 'Napraj vamu', completed: false},
  58. {id:4 ,description: 'Napraj tamu', completed: false},
  59. {id:5 ,description: 'Skini picka', completed: true},
  60. ]
  61. },
  62. methods:{
  63. finish(event, id){
  64. this.tasks[id].completed = true;
  65. },
  66. unfinish(event, id){
  67. this.tasks[id].completed = false;
  68. }
  69. },
  70. computed:{
  71. incomleteTasks(){
  72. return this.tasks.filter(task => ! task.completed);
  73. },
  74. completeTasks(){
  75. return this.tasks.filter(task => task.completed);
  76. }
  77. }
  78. });
  79.  
  80. </script>
  81.  
  82. </body>
  83. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement