forked from tangjinzhou/biz-mobile-ui
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
44 lines (39 loc) · 1.52 KB
/
index.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="mobile-web-app-capable" content="yes">
<title>biz-mobile-ui</title>
<link rel="stylesheet" href="./dist/app.css">
</head>
<body>
<div id="app"></div>
<script>
(function () {
var dpr, scale;
var docEl = document.documentElement;
var metaEl = document.querySelector('meta[name="viewport"]');
dpr = window.devicePixelRatio || 1;
scale = 1 / dpr;
// 设置viewport,进行缩放,达到高清效果
metaEl.setAttribute('content', 'width='+docEl.getBoundingClientRect().width+',initial-scale=' + scale + ',maximum-scale=' + scale + ', minimum-scale=' + scale + ',user-scalable=no');
// 设置data-dpr属性,留作的css hack之用
docEl.setAttribute('data-dpr', dpr);
var updateView = function(width){
docEl.style.fontSize = width / 10 + 'px';
}
updateView(Math.min(docEl.getBoundingClientRect().width, docEl.getBoundingClientRect().height));
var a = null;
window.addEventListener("resize", function(){
clearTimeout(a);
a = setTimeout(function(){
updateView(Math.min(docEl.getBoundingClientRect().width, docEl.getBoundingClientRect().height));
}, 300);
}, false)
})();
</script>
<script src="./dist/dll.vendor.js"></script>
<script src="./dist/app.js"></script>
</body>
</html>