vue3 rem适配pc

    技术2022-07-17  88

    //1.安装依赖 这里使用的cnpm cnpm i lib-flexible -S cnpm i postcss-pxtorem -D //2.安装完成后在main.js引入 import 'lib-flexible' //3.在package.json中增加 "postcss": { "plugins": { "autoprefixer": {}, "postcss-pxtorem": { "rootValue": 192, //这里根据设计图尺寸 / 10 "propList": [ "*" ] } } }, //4.需要修改node_modules/lib-flexble/flexble.js源文件 function refreshRem(){ var width = docEl.getBoundingClientRect().width; if (width / dpr > 540) { width = width * dpr; } var rem = width / 10; docEl.style.fontSize = rem + 'px'; flexible.rem = win.rem = rem; } //5.重新启动 cnpm run serve
    Processed: 0.014, SQL: 9