-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path22.组件.html
48 lines (45 loc) · 1003 Bytes
/
22.组件.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">
<title>组件</title>
</head>
<body>
<div id="app">
<hello></hello>
<hello></hello>
<hello></hello>
</div>
<template id="tmp">
<ul>
<li>home<world></world></li>
<li>23</li>
<li>45</li>
</ul>
</template>
<div id="example">
<my-component></my-component>
</div>
<script src="vue.js"></script>
<script>
var hello = Vue.extend({
template:'#tmp'
});
var world = Vue.extend({
template:'<div>world</div>'
});
//Vue注册组件
Vue.component('hello',hello);
Vue.component('world',world);
var vm = new Vue({
el:'#app'
});
Vue.component('my-component',{
template:'<div>这个是使用组件生成的文本</div>'
});
var example = new Vue({
el:'#example'
});
</script>
</body>
</html>