-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsecond.html
48 lines (48 loc) · 1.6 KB
/
second.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 lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- 开发环境版本,包含了有帮助的命令行警告 -->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<title>Document</title>
</head>
<body>
<!-- 使用 v-bind 指令将待办项传到循环输出的每个组件中 -->
<div id = "app-7">
<!-- orderlist 本身就会生成有序号的列表 -->
<ol>
<!-- 创建一个 todo-item 组件的实例 -->
<!-- 我们为每个 todo-item 提供 todo 对象 -->
<!-- todo 对象是变量,即其内容可以是动态的 -->
<!-- 尽量少用空格隔开内容,可能会导致失效 -->
<todo-item
v-for="item in groceryList"
v-bind:todo="item"
v-bind:key="item.id"
></todo-item>
</ol>
</div>
</body>
<script>
Vue.component('todo-item' , {
// todo-item 组件现在接受一个
// "prop",类似于一个自定义 attribute。
// 这个 prop 名为 todo
props : ['todo'],
template : '<li>{{todo.id +" "+todo.text}}</li>'
})
//数组保存内容,id 是从 0 开始的
var app7 = new Vue({
el: '#app-7',
data: {
groceryList: [
{ id: 0, text: '蔬菜' },
{ id: 1, text: '奶酪' },
{ id: 2, text: '随便其它什么人吃的东西' }
]
}
})
</script>
</html>