forked from tangjinzhou/geektime-vue-1
-
Notifications
You must be signed in to change notification settings - Fork 502
/
index.html
47 lines (44 loc) · 1.02 KB
/
index.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
<html>
<head>
<style>
.item {
color: red;
}
</style>
</head>
<body>
<div id="app">
{{msg}}
<div>
<input type="text" v-model="info">
<button @click="handleClick">添加</button>
</div>
<ul>
<todo-item v-for="item in list" :item="item"></todo-item>
</ul>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<script>
Vue.component('todo-item', {
props: ['item'],
template: '<li class="item">{{item}}</li>'
})
new Vue({
el: '#app',
data() {
return {
msg: 'hello geektime',
info: '',
list: [],
}
},
methods: {
handleClick() {
this.list.push(this.info)
this.info = ''
}
}
})
</script>
</body>
</html>