-
Notifications
You must be signed in to change notification settings - Fork 0
/
data博文数组.html
44 lines (39 loc) · 1001 Bytes
/
data博文数组.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vue Button Counter Example</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
</head>
<body>
<div id="demo">
<blog-post
v-for="post in posts"
v-bind:key="post.id"
v-bind:title="post.title"
>
</blog-post>
</div>
</div>
<script>
// 定义一个名为 button-counter 的新组件
Vue.component("blog-post", {
props:['title'],
template:
'<h2>{{title}}</h2>',
});
// 创建一个 Vue 根实例,用于挂载包含组件的元素
new Vue({
el: '#demo',
data: {
posts: [
{ id: 1, title: 'My journey with Vue' },
{ id: 2, title: 'Blogging with Vue' },
{ id: 3, title: 'Why Vue is so fun' }
]
}
});
</script>
</body>
</html>