同步MU
看一下打包的loader的版本对应不对应,
慕粉3296108
写样式的时候必须要先已一个确定的屏幕(375px)来作为参考,这里只是为了得到一个确定的倍数($px/$rem),css里字体的变化是根据页面根元素<html>的font-size变化的。
飞翔的胡先森
wu wu
fengyw
噢噢,我明白了,那个function只是用来返回一个正确的倍数的
Helianthuserin
可忽略
梁凤波
qq_吃的舍得_0
我是这样减少获取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';
})