-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path12demo.html
119 lines (96 loc) · 2.8 KB
/
12demo.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no">
<title>vue 12demo</title>
<script type="text/javascript" src="./js/vue.js"></script>
<script type="text/javascript" src="./js/vuex.js"></script>
</head>
<style lang="">
* {
margin: 0;
padding: 0;
}
li {
list-style: none;
}
#header {
width: 100%;
height: 40px;
line-height: 40px;
background-color: #666;
color: #fff;
text-align: center;
}
#header button {
height: 100%;
padding: 0 5px;
}
#header button:nth-of-type(1) {
float: left;
}
#header button:nth-of-type(2) {
float: right;
}
</style>
<body>
<div id="app">
<!-- <div id="header">
<button>返回</button>
通讯录
<button>主页</button>
</div> -->
<!-- <my-header custom-title="通讯录" custom-fixed></my-header> -->
<!-- <my-header></my-header> -->
<my-header custom-title="通讯录" custom-fixed>
<button @touchstart="backBtn" slot="left">返回</button>
<button @touchstart="homeBtn" slot="right">主页</button>
</my-header>
</div>
<script>
Vue.component("my-header", {
// template: `<div id="header" :style="{'position': customFixed ? 'fixed' : 'static'}">
// <button>返回</button>
// {{customTitle}}
// <button>主页</button>
// </div>`,
template: `<div id="header" :style="{'position': customFixed ? 'fixed' : 'static'}">
<slot name="left">返回</slot>
{{customTitle}}
<slot name="right">主页</slot>
</div>`,
props: {
// 转驼峰的方式 custom-title => customTitle
"customTitle": {
type: String,
default: "标题"
},
"customFixed": {
type: Boolean,
default: false
}
}
})
var vm = new Vue({
el: "#app",
methods: {
backBtn: function() {
alert("backBtn")
},
homeBtn: function() {
alert("homeBtn")
},
},
})
/*
Vue 组件开发流程
编写基础HTML和CSS
提取出组件
数据传输
内容分发
添加事件与方法
*/
</script>
</body>
</html>