vue3.0+vite 使用 postcss-pxtorem 實現移動自適應


下載 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’

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM