当我打开控制台时可以访问到我后端接口(http请求),关闭控制台时不却不能正常访问请求
testTap: function (e) {
var n = this;
if (0 != this.verification()) {
t.setStorageSync("baseUrl", ""), t.showLoading({
title: "加载中"
});
var i = this.ip + this.pName,
a = {
url: i + "/api/loginService/test",
method: "get"
};
o.default.httpRequest(a, "").then((function (res) {
if(!res){
wx.showModal({
title:"提示:"+res,
icon: 'error',
duration:2000
})
return false;
}else{
if(res.data.result==1){
if(e=='keep'){
t.setStorageSync('ip',n.ip);
t.setStorageSync('pName',n.pName);
t.setStorageSync('baseUrl',i);
t.showToast({
title:'保存成功',
icon:"none"
})
setTimeout(()=>{
t.navigateBack({
delta: 1
});
},1000)
}else{
t.showToast({
title:'测试成功',
icon:"none"
})
}
}else{
t.showToast({
title:'请输入正确IP地址',
icon:"none"
})
return false;
}
}
}), (function (e) {
return console.log("失败"), t.showToast({
title: "请输入正确端口",
icon: "none"
}), !1
}))
}
},
需要https 并且公众后台添加合法域名