窗口缩放解决方案 来自veb
!function(){var e=document.documentElement;a=function(){var n=e.getBoundingClientRect().width;n<1200&&(n=1200),e.style.fontSize=100/1920*(n>=1920?1920:n)+"px"},c=null,window.addEventListener("resize",function(){clearTimeout(c),c=setTimeout(a,10)}),a()}()
taro
基于 react 的解决方案(京东)
!function(x){function w(){var v,u,t,tes,s=x.document,r=s.documentElement,a=r.getBoundingClientRect().width;if(!v&&!u){var n=!!x.navigator.appVersion.match(/AppleWebKit.*Mobile.*/);v=x.devicePixelRatio;tes=x.devicePixelRatio;v=n?v:1,u=1/v}if(a>=640){r.style.fontSize="40px"}else{if(a<=320){r.style.fontSize="20px"}else{r.style.fontSize=a/320*20+"px"}}}x.addEventListener("resize",function(){w()});w()}(window);
网友评论