有什么通用的吗
有什么通用的放法吗?这样写好麻烦
有什么通用的放法吗?这样写好麻烦
2018-06-03
我是这样减少获取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';
})举报