美文网首页
移动端rem适配

移动端rem适配

作者: buer_jing | 来源:发表于2019-07-23 17:23 被阅读0次
  1. 安装插件
# npm
npm install amfe-flexible -S 
npm install postcss-px2rem -S

# yarn
yarn add amfe-flexible
yarn add postcss-px2rem -D
  1. 在main.js中引入文件
import 'amfe-flexible'
  1. 配置postcss-px2rem
# vue.config.js文件
module.exports = {
  css: {
    loaderOptions: {
      postcss: {
        plugins: [
         pxtorem({
           rootValue: 75, // 设计图的宽度/10
           propList: ['*', '!border*'], // 不匹配边框
         })
        ]
      }
    }
  }
}
# 在css中,使用`/*no*/`表示该属性不进行rem转换

相关文章

网友评论

      本文标题:移动端rem适配

      本文链接:https://www.haomeiwen.com/subject/alualctx.html