1.npm install postcss-pxtorem --save
npm install amfe-flexible --save
2.main.ts
import 'amfe-flexible'
3.vite.config.ts
import postcssPxtorem from 'postcss-pxtorem'
css: {
postcss: {
plugins: [
postcssPxtorem({
rootValue: 192,
propList: ["*", "!border"], // 属性的选择器,*表示通用
unitPrecision: 2, // 保留rem小数点多少位
selectorBlackList: [/^(?!.big-screen).*/], // 忽略的选择器 .ig- 表示 .ig- 开头的都不会转换 只转换需要适配的页面.adapt-page开头的选择器
replace: true,
mediaQuery: true,
},)
]
}
},