This repository has been archived by the owner on Oct 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy path00-component_system.html
130 lines (114 loc) · 2.56 KB
/
00-component_system.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/4.2.0/normalize.css">
<title>Vue - Component System</title>
<style type="text/css">
body {
font-size: 1.8em;
}
#app {
display: block;
width: 1000px;
height: 500px;
overflow: hidden;
}
.header {
width: 100%;
height: 80px;
line-height: 80px;
text-align: center;
background-color: #eee;
}
.main {
position: relative;
width: 60%;
height: 100%;
text-align: center;
background-color: #fff;
float: left;
}
.aside {
width: 40%;
height: 100%;
line-height: 300px;
text-align: center;
background-color: pink;
float: right;
}
.block {
display: inline-block;
width: 85px;
height: 85px;
background-color: green;
margin: 20px;
color: #fff;
font-size: 26px;
line-height: 85px;
text-align: center;
}
</style>
</head>
<body>
<div id="app">
<custom-header msg="Header"></custom-header>
<custom-main></custom-main>
<custom-aside></custom-aside>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.3.4/vue.js"></script>
<script>
var CustomBlock = Vue.extend({
data () {
return {
content: 'B'
}
},
template: '<div class="block">{{ content }}</div>',
});
var CustomMain = Vue.extend({
template: '<div class="main">' +
'<div style="margin: 10px;">MAIN</div>' +
'<custom-block></custom-block>' +
'<custom-block></custom-block>' +
'<custom-block></custom-block>' +
'<custom-block></custom-block>' +
'<custom-block></custom-block>' +
'<custom-block></custom-block>' +
'</div>',
components: {
CustomBlock
}
});
var CustomHeader = Vue.extend({
// template: '<div class="header"> {{ greet }} {{ msg }}</div>',
render: function(createElement){
return createElement('div', {
class: 'header'
}, [this.greet, ' ', this.msg]);
},
data () {
return {
greet: 'Hi'
}
},
props: {
msg: {
type: String,
default: 'Hello'
}
}
});
var CustomAside = Vue.extend({
template: '<div class="aside">Aside</div>',
});
new Vue({
el: '#app',
components: {
CustomMain,
CustomHeader,
CustomAside
}
});
</script>
</body>
</html>