下载 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
}
}
}

  


这里只实现了 px转rem,还要安装 amfe-flexible

npm i amfe-flexible  autoprefixer -D

  

在main.ts文件中 import 一下就好可以了

import ‘amfe-flexible/index.js’

  

 

posted on 2022-01-26 17:37  ygunoil  阅读(1117)  评论(0)    收藏  举报