一、安装
npm install px2rem-loader lib-flexible --save
二、入口文件main.js加上
import 'lib-flexible/flexible.js'
三、在index.html加上
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
四、在build下的 utils.js中加上
const px2remLoader = { loader: 'px2rem-loader', options: { remUnit: 37.5 } } function generateLoaders (loader, loaderOptions) { const loaders = [cssLoader, px2remLoader] if (loader) { loaders.push({ loader: loader + '-loader', options: Object.assign({}, loaderOptions, { sourceMap: options.sourceMap }) }) }