超简单实用的Vue移动端rem解决方案一
首先安装amfe-flexible 、postcss-px2rem插件
postcss-px2rem这个插件的作用是 自动将vue项目中的px转换为rem
npm i amfe-flexible postcss-px2rem -S
在main.js里引入amfe-flexible
import 'amfe-flexible'
在package.json中配置添加这段代码
"postcss": {
"plugins": {
"autoprefixer": {},
"postcss-px2rem": {
"remUnit": 37.5
}
}
}
如果你不想转换成rem,就把px的单位大写PX,就可以啦。