-
Notifications
You must be signed in to change notification settings - Fork 0
/
选择器.html
114 lines (107 loc) · 3.06 KB
/
选择器.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
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<link href="css/mui.min.css" rel="stylesheet" />
<link rel="stylesheet" href="css/mui.poppicker.css" />
<link rel="stylesheet" type="text/css" href="css/mui.picker.css" />
<link rel="stylesheet" type="text/css" href="css/mui.dtpicker.css" />
</head>
<body>
<header class="mui-bar mui-bar-nav">
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
<h1 class="mui-title">栅格</h1>
</header>
<div class="mui-content">
<button type="button">打开选择器</button>
</div>
<script src="js/mui.min.js"></script>
<script src="js/mui.picker.js" type="text/javascript" charset="utf-8"></script>
<script src="js/mui.poppicker.js" type="text/javascript" charset="utf-8"></script>
<script src="js/mui.dtpicker.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
mui.init();
/* var picker = new mui.PopPicker();
picker.setData([{
value: "first",
text: "第一项"
}, {
value: "second",
text: "第一项"
}, {
value: "third",
text: "第三项"
}, {
value: "fourth",
text: "第四项"
}, {
value: "fifth",
text: "第五项"
}])
//picker.pickers[0].setSelectedIndex(4, 2000);
picker.pickers[0].setSelectedValue('fourth', 2000); //默认选中value项
picker.show(function(SelectedItem) {
console.log(selectItems[0].text); //第一项
console.log(selectItems[0].value); //first
})*/
/* var picker = new mui.PopPicker({
layer: 2 //显示列数
});
picker.setData([{
value: '110000',
text: '北京市',
children: [{
value: "110101",
text: "东城区"
}]
}, {
value: '120000',
text: '天津市',
children: [{
value: "120101",
text: "和平区"
}, {
value: "120102",
text: "河东区"
}, {
value: "120104",
text: "南开区"
}]
}])
picker.pickers[0].setSelectedIndex(1,200);
picker.pickers[1].setSelectedIndex(1,200);
picker.show(function(SelectedItem) {
console.log(SelectedItem);
})*/
var time = new Date();
var dtPicker = new mui.DtPicker({
type: 'date',
customData: {
'h': [{
value: 'am',
text: '上午'
}, {
value: 'pm',
text: '下午'
}]
},
endDate: new Date(time.getFullYear(), time.getMonth(), time.getDate())
});
mui(document.body).on('tap', 'button',
function(e) {
dtPicker.show(function(selectItems) {
console.log(selectItems);
console.log(selectItems.h); //{value: "am", text: "上午"}
console.log(selectItems.y); //{text: "2016",value: 2016}
console.log(selectItems.m); //{text: "05",value: "05"}
});
});
mui(document.body).on('tap', '.mui-dtpicker-header .mui-btn',
function(e) {
dtPicker.hide()
});
</script>
</body>
</html>