VUE 给生产环境和发布环境配置不同的接口地址,
1./config/dev.env.js文件夹
module.exports = merge(prodEnv, {
NODE_ENV:'"development"',
API_ROOT:'"//192.168.0.2/api"'
})
2.prod.env.js文件
module.exports = {
NODE_ENV:'"production"',
API_ROOT:'"//www.****.com/api"'
}
3. 配置API接口地址
var root = process.env.API_ROOT
this.axios.post(root + '/api-auth/do-login',qs.stringify({
loginName: this.form.loginName,
password: this.form.password,
})).then(res => {}).catch(err => {})
Request URL:
http://192.168.0.2/api/api-auth/do-login