jhzh
2024-10-23 e24d8c01f2f789783b2b180a4f8e1761a3385326
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const baseSize = 16
function setRem() {
    const scale = document.documentElement.clientWidth / 828
    document.documentElement.style.fontSize = baseSize * scale + 'px'
}
function isMobile() {
    let userAgentInfo = navigator.userAgent;
    let Agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod'];
    let getArr = Agents.filter(i => userAgentInfo.includes(i));
    return getArr.length ? true : false;
}
if (isMobile()) {
    setRem()
}
window.onresize = function () {
    if (isMobile()) {
        setRem()
    }
 
}