# 首先下载 cnpm install lib-flexible postcss-plugin-px2rem --save-dev
# 完成下载之后
main.js 导入: import ‘lib-flexible/flexible’;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| module.exports = { css: { loaderOptions: { postcss: { plugins: [ require('postcss-plugin-px2rem')({ rootValue:75, exclude: /node_modules/i, mediaQuery: false, minPixelValue: 3 }), ] } } }, }
|
已完成
# vue 中配置多环境变量
1 2 3 4 5
| "serve": "vue-cli-service serve", "build": "vue-cli-service build", "stage": "vue-cli-service build --mode staging", "lint": "vue-cli-service lint"
|
1.在根目录下创建
.env.development
.env.production
.env.staging
对应的分别是开发模式,生产模式,测试模式
2.在src中创建一个config文件夹里面创建
index.js
env.development.js
env.production.js
env.staging.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
NODE_ENV='development' # must start with VUE_APP_ VUE_APP_ENV = 'development' NODE_ENV='production' # must start with VUE_APP_ VUE_APP_ENV = 'production' NODE_ENV='production' # must start with VUE_APP_ VUE_APP_ENV = 'staging'
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
module.exports = { title: 'vue-h5-template', baseUrl: 'https://www.365msmk.com/api', baseApi: 'https://test.xxx.com/api', APPID: 'xxx', APPSECRET: 'xxx', $cdn: 'https://gimg2.baidu.com' }
import { baseUrl } from '../config' console.log(baseUrl) const instance = axios.create({ baseURL: baseUrl, timeout: 5000 })
|