适配问题
pxtorem插件
postcss-pxtorem
//postcss.config.js
module.exports = {
"plugins": {
"postcss-pxtorem": {
rootValue: 75, // 根据设计图尺寸写,设计图是750,就写75
propList: ['*'] // 需要被转换的属性
}
}
}
但是vant是基于375写的
module.exports = {
"plugins": {
"postcss-pxtorem": {
rootValue({ file }) {
return file.indexOf('vant') !== -1 ? 37.5 : 75;
},
propList: ['*'] // 需要被转换的属性
}
}
}
viewport方案
postcss-px-to-viewport