方法一 flexible
一、npm 包安装
lib-flexible 淘宝适配方案
px2rem px自动转rem
npm install lib-flexible --save
npm install px2rem-loader
二、在main.js中引入lib-flexible**
import ‘lib-flexible/flexible.js‘
三、配置build/utils.js
var px2remLoader = {
loader: ‘px2rem-loader‘,
options: {
remUnit: 75
}
}
// generate loader string to be used with extract text plugin
function generateLoaders (loader, loaderOptions) {
var loaders = [cssLoader,px2remLoader]
if (loader) {
loaders.push({
loader: loader + ‘-loader‘,
options: Object.assign({}, loaderOptions, {
sourceMap: options.sourceMap
})
})
}
方法二媒体查询