File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < title > 综合</ title >
6
+ < script src ="../js/vue.js "> </ script >
7
+ </ head >
8
+ < body >
9
+ < div id ="app ">
10
+ < input v-model ="newTodo " v-on:keyup.enter ="addTodo "/>
11
+ < ul >
12
+ < li v-for ="todo in todos ">
13
+ < span > {{ todo.text }}</ span >
14
+ < button v-on:click ="removeTodo($index) "> X</ button >
15
+ </ li >
16
+ </ ul >
17
+ </ div >
18
+ </ body >
19
+ < script >
20
+ new Vue ( {
21
+ el :'#app' ,
22
+ data :{
23
+ newTodo :'' ,
24
+ todos :[
25
+ { text :'Add Some Todo' }
26
+ ]
27
+ } ,
28
+ methods :{
29
+ addTodo :function ( ) {
30
+ var text = this . newTodo . trim ( ) ;
31
+ if ( text ) {
32
+ this . todos . push ( { text :text } ) ;
33
+ this . newTodo = '' ;
34
+ }
35
+ } ,
36
+ removeTodo :function ( index ) {
37
+ this . todos . splice ( index , 1 ) ;
38
+ }
39
+ }
40
+ } )
41
+ </ script >
42
+ </ html >
You can’t perform that action at this time.
0 commit comments