1、首先在项目中安装以下依赖
npm install px2rem-loader --save
npm install amfe-flexible --save
npm install postcss-px2rem --save
2、在main.js中添加:
import 'amfe-flexible'
3、在vue.config.js中进行配置
module.exports = {
css: {
loaderOptions: {
postcss: {
plugins: [
require('postcss-px2rem')({remUnit: 37.5}),
]
}
}
},
}