1、安装lib-flexiblenpminstalllib-flexibleoryarnaddlib-flexible2,在vue项目'lib-的main.js中引入importflexible'3、修改node_modules/lib-flexible/flexible.js源码函数refreshRem(){varwidth=docEl.getBoundingClientRect().width;如果(宽度/dpr<1280){宽度=1280*dpr;}else{宽度=宽度*dpr;}varrem=宽度/24;docEl.style.fontSize=rem+'px';flexible.rem=win.rem=rem;}4.安装postcss-px2rem-excludenpminstallpostcss-px2rem-exclude-D或者yarnaddpostcss-px2rem-exclude-D5,addpostcss.config.jsmodule.exports={plugins:{autoprefixer:{},"postcss-px2rem-exclude":{remUnit:80,//这里是lib-flexible计算出来的html根节点的font-size值exclude:/node_modules|element-ui/i//需要忽略的文件夹}}}
