vue、移动端自适应配置
1.引入amfe-flexible和postcss-pxtorem
amfe-flexible是配置可伸缩布局方案,主要是将1rem设为viewWidth/10。
postcss-pxtorem是postcss的插件,用于将像素单元生成rem单位。
npm install amfe-flexible --save
npm install postcss-pxtorem --save
2.main.js引入
import 'amfe-flexible';
3.增加postcss.config.js
在src同级目录增加配置文件postcss.config.js
module.exports = {
plugins: {
autoprefixer: {
overrideBrowserslist: ['Android 4.1', 'iOS 7.1', 'Chrome > 31', 'ff > 31', 'ie >= 8']
},
'postcss-pxtorem': {
rootValue: 192,
propList: ['*'],
},
},
};
完成!