vue中px转rem插件

1.amfe-flexible

  • 根据网页宽度自动更改html字体大小
  • yarn add amfe-flexible -S
  • npm i amfe-flexible -S
  • main.js中引入import "amfe-flexible"

2.postcss

  • 下载yarn add postcss postcss-pxtorem@5.1.1 -D
  • 自动将px转换为rem
  • 根目录下创建postcss.config.js文件
module.exports = {
  plugins: {
    'postcss-pxtorem': {
      rootValue: 37.5,
      propList: ['*']
    }
  }
}

评论

暂无评论