创建js文件代码如下当前尺寸是320
根据设计图尺寸不一样做出相应的修改就好
(function(doc,win){
var docEl =doc.documentElement,
resizeEVent = "orientationchange"in window ? "orientationchange" :"resize"
recalc = function(){
var clientWidth = docEl.clientWidth
if(!clientWidth) return;
docEl.style.fontSize= 20 * (clientWidth /320) +"px"
}
if(!doc.addEventListener) return;
win.addEventListener(resizeEVent,recalc,false);
doc.addEventListener("DOMContentLoaded",recalc,false)
})(document,window)
使用时只需要在main.js
import "./config/rem";