vue移动端转rem,px2rem-loader使用方法

可以自动转rem

"px2rem-loader": "^0.1.9",
npm install px2rem-loader --save

在build文件下的utils.js文件中配置


  const px2remLoader = {
    loader: 'px2rem-loader',
    options: {
      remUnit:37.5, // 设计稿的1/10
      // remPrecision: 8
    }
  }
 

在index.html中写入

<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">

之后,直接写px就可以了,浏览器自动转成rem格式

猜你喜欢

转载自blog.csdn.net/xr510002594/article/details/87863575