配置
安裝1:npm i postcss-px2rem --save -dev
安裝2:npm i lib-flexible --save
(在項目中啓動vue ui也可以快速安裝)
配置1:入口文件main.js中引入:import 'lib-flexible/flexible.js'
配置2: 在vue.config.js
module.exports = {
css: {
loaderOptions: {
css: {
// options here will be passed to css-loader
},
postcss: {
// options here will be passed to postcss-loader
plugins: [require('postcss-px2rem')({
remUnit: 75 //設計稿的尺寸是750px 就需要除2,這裏是375px
})]
}
}
}
};