安装amfe-flexible
(用于设置 rem 基准值)
yarn add amfe-flexible
or
npm i -S amfe-flexible
使用amfe-flexible
// src/main.js 中引入 amfe-flexible
import 'amfe-flexible'
安装 postcss-pxtorem(postcss-pxtorem是一款 postcss 插件,用于将单位转化为 rem)
注意 版本太高会报错,需要安装指定版本
npm install postcss-pxtorem@5.1.1 --save-dev
or
yarn add postcss-pxtorem@5.1.1
# 安装loader
npm install postcss-loader@6.1.1 --save-dev
or
yarn add postcss-loader@6.1.1
# 安装autoprefixer
npm install autoprefixer@8.0.0 --save-dev
or
yarn add autoprefixer@8.0.0
index.html
中添加meta
标签
// src/public/index.html viewport 标签替换为如下内容
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">