注意:项目中使用rem为单位
安装postcss-px2rem
cnpm i postcss-px2rem -S
配置postcss-px2rem
//vue.config.js
module.exports = {
css: {
loaderOptions: {
css: {},
postcss: {
plugins: [
require('postcss-px2rem')({
remUnit: 37.5
})
]
}
}
}
}
安装amfe-flexible
cnpm i amfe-flexible -S
配置amfe-flexible
//.main.js
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import 'amfe-flexible'
Vue.config.productionTip = false
new Vue({
router,
store,
render: h => h(App)
}).$mount('#app')