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 }

 

posted @ 2019-01-15 16:09  _小狐狸  阅读(1204)  评论(0编辑  收藏  举报