function fn(){ console.log(11111); function setHtmlFontSize() { let whdef = 100 / 1920 ; let bodyWidth = document.documentElement.getBoundingClientRect().width; console.log(bodyWidth,'屏幕宽度') let rem = bodyWidth * whdef document.getElementsByTagName('html')[0].style.fontSize = rem + 'px' } setHtmlFontSize() window.addEventListener('resize',function(){ setTimeout(function(){ setHtmlFontSize() },100) }) } fn()