Always|

李云蹊

园龄:2年11个月粉丝:33关注:5

vue+vant项目中 rem适配配置

vant rem适配,需要安装两个插件

  • postcss-pxtorem 是一款 postcss 插件,用于将单位转化为 rem  
  • lib-flexible 用于设置 rem 基准值

postcss-pxtorem:

npm install postcss-pxtorem --save-dev

lib-flexible:

npm i -S amfe-flexible

main.js 引入amfe-flexible

import 'amfe-flexible/index.js'

在postcss.config.js文件内(没有就在根目录创建一个)

module.exports = {
  plugins: {
    'autoprefixer': {
      overrideBrowserslist: [
        'Android 4.1',
        'iOS 7.1',
        'Chrome > 31',
        'ff > 31',
        'ie >= 8'
      ]
    },
    'postcss-pxtorem': {
      rootValue: 100,
      propList: ['*']
    }
  }
}

重启项目

 

注意:

border使用px,不转化为rem方法:   大写PX ,例:1PX solid #f00;

本文作者:liyunxi

本文链接:https://www.cnblogs.com/liyunxi/p/17172972.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   李云蹊  阅读(457)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起