-
Notifications
You must be signed in to change notification settings - Fork 0
/
2-3index.html
48 lines (46 loc) · 890 Bytes
/
2-3index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>TOdolist以及全局组件局部组件</title>
<script src="vue.js"></script>
</head>
<body>
<div id="app">
<input type="text" v-model="booksName">
<button @click="submit">提交</button>
<ul>
<!-- <li v-for="book in Books">{{book}}</li> -->
<todo-item v-for="book in Books" :content="book"></todo-item>
</ul>
</div>
</body>
<script>
//全局组件
// Vue.component("TodoItem",{
// props:['content'],
// template:'<li>{{content}}</li>'
// })
//局部组件
var TodoItem={
props:['content'],
template:'<li>{{content}}</li>'
}
var app=new Vue({
el:"#app",
data:{
Books:[],
booksName:'',
},
components:{
TodoItem
},
methods:{
submit(){
this.Books.push(this.booksName);
this.booksName=''
}
}
})
</script>
</html>