<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>哈哈哈</title>
<style>
body::-webkit-scrollbar {
width: 0 !important
}
body {
-ms-overflow-style: none;
overflow: -moz-scrollbars-none;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
<script>
// 1、尺寸自适应
let mobileSize = 750,
pcSize = 1920,
middleSize = 1200, // 兼容pc端嵌入的盒子是1200的
ev = "orientationchange" in window ? "orientationchange" : "resize";
let fontAdaptive = () => {
let customSize = document.documentElement.clientWidth || document.body.clientWidth,
standardSize = null;
if (customSize) {
standardSize = customSize >= middleSize ? pcSize : mobileSize;
customSize = customSize >= middleSize ? pcSize :
customSize >= mobileSize ? mobileSize : customSize;
document.documentElement.style.fontSize = customSize / standardSize * 625 + "%";
}
};
fontAdaptive();
window.addEventListener && window.addEventListener(ev, fontAdaptive, false);
document.addEventListener && document.addEventListener("DOMContentLoaded", fontAdaptive, false);
// 2、禁止双指放大
document.documentElement.addEventListener('touchmove', event => {
if (event.touches.length > 1) {
event.preventDefault();
}
}, false);
// 3、禁止双击放大
let lastTouchEnd = 0;
document.documentElement.addEventListener('touchend', event => {
let now = Date.now();
if (now - lastTouchEnd <= 300) {
event.preventDefault();
}
lastTouchEnd = now;
}, false);
</script>
</body>
</html>