在前端调接口时 遇到接口地址很多的项目 打包时换来换去很麻烦 所以运用window.location.href来判断一下 (针对于封装的接口地址)
var baseUrl =''
if (window.location.href.indexOf('http://localhost:808') == 0 || window.location.href.indexOf('xxxx') == 0) {
baseUrl = 'xxxx'
console.log('本地活测试地址');
} else if(window.location.href.indexOf('xxx') == 0){
console.log('线上地址');
baseUrl = 'xxx/'
} else if (window.location.href.indexOf('xxx') == 0) {
baseUrl = 'xxx'
}
封装参考:axios二次封装_^_^-CSDN博客_axios 二次封装 、vue 封装axios 并省略写 data、params参数_^_^-CSDN博客