需求描述
测试环境192.268.224.114里请求192.268.224.112的接口,showip为192.268.224.112,
测试环境192.268.224.113里请求192.268.224.111的数据,ip地址得写192.268.224.111;
实现方法如下:
environment.ts配置
export const environment = {
showip:"http://192.168.224.112"
};
在接口文件xx.service.ts文件里加判断
//引入environment中的showip
import { environment } from "../../../environments/environment";
showip:string = environment.showip
//获取快捷导航(GS7里控制权限)
getNavItem(UserCode, Phone, Menus: Array<string>) {
let usercode = JSON.stringify(UserCode)
let phone = JSON.stringify(Phone)
let jsonarr = JSON.stringify(Menus)
const body = {
"strPara": `{"UserCode": ${usercode},"Phone": ${phone},"Menus": ${jsonarr}}`
}
//判断ip地址
if(window.location.hostname==="192.168.224.114"){
this.showip="192.168.224.112"
}else if(window.location.hostname==="192.168.224.113"){
this.showip="192.168.224.111"
}
return
//使用showip
this.http.post(`http://${this.showip}/cwbase/jtgl/Srv/CheckMenuPerm.asmx/CheckMenuPermMethod`, body);
}