1.安装
npm i postcss-pxtorem -D
npm i amfe-flexible
或 yarn add
2.修改根目录下的postcss.config.js 文件(如果没有这个文件,可以手动添加一份)
3.修改根目录下的postcss.config.js 文件
module.exports = {
plugins: {
'autoprefixer': {},
'postcss-pxtorem': {
rootValue: 37.5,
propList: ['*']
}
}
}
4.在main.js里面引入 amfe-flexible
import 'amfe-flexible'
5.如果报错 PostCSS plugin postcss-pxtorem requires PostCSS 8. 安装低版本
npm uninstall postcss-pxtorem
npm i postcss-pxtorem@5.1.1