1function remRefresh() { 2 let clientWidth = document.documentElement.clientWidth; 3 // 将屏幕分成10等份 4 let rem = clientWidth / 10; 5 document.documentElement.style.fontSize = rem + 'px' 6 document.body.style.fontSize = '12px' 7} 8 9window.addEventListener('pageshow', () => { 10 remRefresh() 11}) 12 13// 函数防抖 14let timeoutId; 15window.addEventListener('resize', () => { 16 timeoutId && clearTimeout(timeoutId); 17 timeoutId = setTimeout(() => { 18 remRefresh() 19 }, 300) 20})
移动端rem.js

LinMeng
2022-10-27
1372 1 0
点赞
收藏
评论区
加载中...