vue中rem的转换
1 function rems(doc: any, win: any): void { 2 let docEl = doc.documentElement, 3 resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize', 4 recalc = function () { 5 let clientWidth = docEl.clientWidth; 6 if (!clientWidth) return; 7 docEl.style.fontSize = 20 * (clientWidth / 750) + 'px'; 8 }; 9 if (!doc.addEventListener) return; 10 win.addEventListener(resizeEvt, recalc, false); 11 doc.addEventListener('DOMContentLoaded', recalc, false); 12 } 13 export default { 14 return : rems(document,window) 15 }
本文来自博客园,作者:_小狐狸,转载请注明原文链接:https://www.cnblogs.com/zwh520/p/10272520.html