px转换rem的插件

2021-08-12  本文已影响0人  浅浅_2d5a

安装
cnpm i postcss-pxtorem -S
cnpm i amfe-flexible -S
main.js中引入
// rem h5 适配
import 'amfe-flexible/index.js'
vue.config.js中的配置

module.exports={
    css: {
      loaderOptions: {
        postcss: {
            plugins: [
                require('autoprefixer')({
                    overrideBrowserslist:["last 15 versions"]
                }),
                require('postcss-pxtorem')({
                    rootValue: 37.5,
                    propList: ['*'],
                    exclude: /node_modules/
                })
            ]
        }
      }
    },
}

如果涉及1px的,可以写成1Px,或者1PX

上一篇 下一篇

猜你喜欢

热点阅读