vue区分线上环境和本地开发环境
config/dev.env.js'use strict'const merge = require('webpack-merge')const prodEnv = require('./prod.env')module.exports = merge(prodEnv, {NODE_ENV: '"development"',API_ROOT: '&quo
·
config/dev.env.js
'use strict'
const merge = require('webpack-merge')
const prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {
NODE_ENV: '"development"',
API_ROOT: '"http://192.168.1.14:8080/api/"'
})
config/prod.env.js
'use strict'
module.exports = {
NODE_ENV: '"production"',
API_ROOT: '"http://www.*******.com/dididcarapi/"',
// 将上文设置的环境变量,赋值到 type 属性上
type: process.env.type
}
config/index.js
dev: {
// 反向代理解决跨域
proxyTable: {
'/api': { //将http://192.168.1.51:8080/grain印射为/api
target: 'http://192.168.1.67:8080/dididcarapi',//接口域名
// target: 'http://www.91dadi.com/dididcarapi/',//接口域名
changeOrigin: true,//是否跨域
pathRewrite: {
'^/api': ''
}
}
},
}
src/config/index.js
export default {
install : function(Vue) {
var root = process.env.API_ROOT;
Vue.prototype.root = root;
}
}
src/main.js
import './config'
更多推荐
已为社区贡献16条内容
所有评论(0)