vue中px转rem

1,031 阅读1分钟

amfe-flexible

根据网页宽度自动更改html字体大小

// yarn add amfe-flexible -S 或 npm i amfe-flexible -S
// 在入口文件中引入
import "amfe-flexible"

postcss

// npm i postcss postcss-pxtorem@5.1.1 -D
// yarn add postcss postcss-pxtorem@5.1.1 -D
// 根目录下创建postcss.config.js文件,写入如下:
module.exports = {
  plugins: {
    'postcss-pxtorem': {
      rootValue: 37.5,
      propList: ['*']
    }
  }
}