1个盆、在main.js文件中:import 'amfe-flexible'
2攻询、在vue.config.js文件中:
2.1漓雅、const autoprefixer = require('autoprefixer')衣迷;const pxtorem = require('postcss-pxtorem');
2.2邮破、 css: {
? ????????? loaderOptions: {
? ? ? ????????postcss: {
? ? ? ? ? ? ? ????plugins: [
? ? ? ? ????? ????????autoprefixer(),
? ? ? ? ? ????????????pxtorem({
? ? ? ? ? ????????????? rootValue: 37.5,
? ? ? ? ? ????????????? propList: ['*']
? ? ? ? ? ????????????})
? ? ? ? ????????????]
? ? ????????????? }
? ? ????????????}
????????????? }
3诈豌、需npm install?amfe-flexible 和npm install?postcss-pxtorem
存在一個問題,就是使用的UI框架里的組件如果有自己api定義大芯龊酢(px);插件無法轉(zhuǎn)化為rem派桩。