看一下打包的loader的版本对应不对应,
写样式的时候必须要先已一个确定的屏幕(375px)来作为参考,这里只是为了得到一个确定的倍数($px/$rem),css里字体的变化是根据页面根元素<html>的font-size变化的。
wu wu
噢噢,我明白了,那个function只是用来返回一个正确的倍数的
可忽略
我是这样减少获取dom的获取:
const bodyDom = document.body; const htmlDom = document.documentElement; const htmlWidth = bodyDom.clientWidth || htmlDom.clientWidth; htmlDom.style.fontSize = htmlWidth / 10 + 'px'; window.addEventListener('resize', (e) => { const htmlWidth = bodyDom.clientWidth || htmlDom.clientWidth; htmlDom.style.fontSize = htmlWidth / 10 + 'px'; })