- 安装postcss-pxtorem: npm i postcss-pxtorem -D
- 与package.json同级目录创建postcss.config.js文件
module.exports = {
plugins: {
autoprefixer: {
overrideBrowserslist: [
"Android 4.1",
"iOS 7.1",
"Chrome > 31",
"ff > 31",
"ie >= 8",
"last 10 versions", // 所有主流浏览器最近10版本用
],
grid: true,
},
'postcss-pxtorem': {
rootValue: 37.5,
propList: ['*'],
unitPrecision: 5
}
}
}
- 安装 amfe-flexible: npm i amfe-flexible -D
- main.js中引入: import ‘amfe-flexible/index.js’