安装 PostCSS 、autoprefixer
、postcss-pxtorem
npm install postcss --save-dev --registry=https://registry.npmmirror.com/
npm install autoprefixer --save-dev --registry=https://registry.npmmirror.com/
npm install postcss-pxtorem --save-dev --registry=https://registry.npmmirror.com/
配置postcss.config.js
//浏览器兼容(-webkit-, -moz-, -ms-, -o- 等)
const autoprefixer = require('autoprefixer');
// 用于将px单位转化为rem单位
const pxtorem = require('postcss-pxtorem');
module.exports = ({ file }) => {
return {
plugins: [
autoprefixer(),
pxtorem({
rootValue: 37.5,
propList: ['*'],
minPixelValue: 2
})
]
};
};
重启Visual Studio Code生效
