1. 下载 npm install -s postcss-plugin-px2rem

2.在根文件夹中创建 .postcssrc.js

  module.exports = {
      "plugins": {
            "postcss-plugin-px2rem": {
              rootValue: 100,
            }
          }
  }
 
3.创建rem.js 文件 ,因为这个插件 只会转成rem,并不会设置页面字体 大小
  (function () {
      var clientWidth = document.documentElement ? document.documentElement.clientWidth : document.body.clientWidth;
        if (clientWidth > 750) clientWidth = 750;
        document.documentElement.style.fontSize = clientWidth * 1 / 3.75 + "px";
        return clientWidth * 1 / 3.75;
  })();
 
4. 在main.js导入 rem.js
posted on 2022-04-08 14:08  94汪  阅读(1331)  评论(0)    收藏  举报