-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomp_basic2.html
44 lines (41 loc) · 954 Bytes
/
comp_basic2.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
<!-- 开发环境版本,包含了有帮助的命令行警告 -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<title>Component basic</title>
</head>
<body>
<div id="components-demo">
<blog-post
v-for="post in posts"
v-bind:key="post.id"
v-bind:post="post"
>
</blog-post>
</div>
<script>
// blog-post
Vue.component('blog-post', {
props: ['post'],
template: `
<div class="blog-post">
<h3>{{ post.title }}</h3>
<div v-html="post.content"></div>
</div>
`
});
var example = new Vue({
el: '#components-demo',
data: {
posts: [
{ id: 1, title: 'My journey with Vue', content: 'content1' },
{ id: 2, title: 'Blogging with Vue', content: 'content2' },
{ id: 3, title: 'Why Vue is so fun', content: 'content3' }
]
}
});
</script>
</body>
</html>