移动端自适应安装插件以及配置
1. 安装 node 版本
> v10.16.3
2. 安装 vue-cli
> npm install -g @vue/cli@4.5.12
3. 构建 vue 项目
步骤:
1. vue create mobile-web
2. Manually
3. Bable,Router,Vuex,Linter / Formatter
4. N
5. ESLint with error prevention only
6. Lint on save
7. In dedicated config files
4. 安装 vue 项目自适应插件
> npm install amfe-flexible@2.2.1 postcss-pxtorem@5.1.1 autoprefixer@8.0.0 -S
5. 配置
1. 在 main.js 中 引用
> import 'amfe-flexible'
2. 在 vue.config.js 中配置
```js
const path = require('path'); // autoprefixer主要配合打包自动添加css浏览器兼容前缀
const autoprefixer = require('autoprefixer'); // 将像素生成rem
const pxtorem = require('postcss-pxtorem');
module.exports = {
lintOnSave: false,
productionSourceMap: true,
configureWebpack: (config) => {
config.resolve = { // 配置解析别名
extensions: ['.js', '.json', '.vue'], // 自动添加文件名后缀
alias: {
// 'vue': 'vue/dist/vue.js',
'@': path.resolve(__dirname, './src')
}
}
},
css: {
loaderOptions: {
postcss: {
plugins: [
autoprefixer(),
pxtorem({
rootValue: 37.5,
propList: ['*']
})
]
}
}
}
}
```

浙公网安备 33010602011771号