適配准備
安裝 (amfe-flexible) 和(postcss-px2rem)
1, 安裝依賴並在main.js中引入該依賴
npm i amfe-flexible
import “amfe-flexible”
2,安裝第二依賴
npm i postcss-px2rem
並在paackage.json中配置此依賴
"postcss": {
"plugins": {
"autoprefixer": {},
"postcss-px2rem": {
"remUnit": 192 //設計稿的除以10得到適配范圍
}
}
}
然后重啟項目,會幫我們自動轉換的px為rem來進行適配