File tree 2 files changed +38
-0
lines changed
2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ import ExerciseForm from '@/exercise-2' ;
2
+ import { mount } from '@vue/test-utils' ;
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div >
3
+ <form @submit.prevent =" addTask" >
4
+ <input type =" text" v-model =" newTask" placeholder =" Add a task" />
5
+ <button type =" submit" >Add</button >
6
+ </form >
7
+ <h2 >Tasks</h2 >
8
+ <ul >
9
+ <li v-for =" (task, index) in tasks" :key =" task" >
10
+ {{ task }}
11
+ <button @click =" remove(index)" >Done</button >
12
+ </li >
13
+ </ul >
14
+ </div >
15
+ </template >
16
+
17
+ <script >
18
+ export default {
19
+ data () {
20
+ return {
21
+ tasks: [],
22
+ newTask: ' '
23
+ };
24
+ },
25
+ methods: {
26
+ addTask () {
27
+ if (this .newTask .trim ().length === 0 ) return ;
28
+ this .tasks .push (this .newTask );
29
+ this .newTask = ' ' ;
30
+ },
31
+ remove (index ) {
32
+ this .tasks .splice (index, 1 );
33
+ }
34
+ }
35
+ };
36
+ </script >
You can’t perform that action at this time.
0 commit comments