app显示服务器借口错误,hbuider 运行 uni-app 电脑端安卓模拟器接口请求错误
1、當(dāng)我ulr設(shè)置為本地服務(wù)器接口時(shí)候,例如:
? ? ? ? ----》? ? ??
login:function(index) {
uni.request({
url: ‘/api/user/login‘,
header: {
‘content-type‘: ‘a(chǎn)pplication/json‘,
},
method: ‘POST‘,
sslVerify: false,//不驗(yàn)證ssl證書
data: {
userName: this.mobile,
passWord: this.password,
userCode: ‘‘,
sysCode: ‘‘
},
success: res => {
console.log(res.data);
if(res.data.code == 0) {
this.login_success = ‘登錄‘ + res.data.message;
}
},
fail: err => {
console.log(err);
uni.showToast({
icon: ‘none‘,
title: "請求錯(cuò)誤!"
})
},
});
},
運(yùn)行到瀏覽器成功,但是安卓模擬器提示:報(bào)錯(cuò):"errMsg": "request:fail abort statusCode:-1"
2、修改utl地址:localhost換成本地ip ,url為我本地的IP地址加端口號8080(IP地址可以windows+R,ipconfig獲取)
此時(shí)模擬器可以獲取數(shù)據(jù),但瀏覽器獲取數(shù)據(jù)失敗(正式環(huán)境地址沒測試過,不知道)
login:function(index) {
uni.request({
url: url + ‘/api/user/login‘,
header: {
‘content-type‘: ‘a(chǎn)pplication/json‘,
},
method: ‘POST‘,
sslVerify: false,//不驗(yàn)證ssl證書
data: {
userName: this.mobile,
passWord: this.password,
userCode: ‘‘,
sysCode: ‘‘
},
success: res => {
console.log(res.data);
if(res.data.code == 0) {
this.login_success = ‘登錄‘ + res.data.message;
}
},
fail: err => {
console.log(err);
uni.showToast({
icon: ‘none‘,
title: "請求錯(cuò)誤!"
})
},
});
},
原文:https://www.cnblogs.com/moguzi12345/p/13042159.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的app显示服务器借口错误,hbuider 运行 uni-app 电脑端安卓模拟器接口请求错误的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 文件服务器+好处,文件服务器 好处
- 下一篇: websocket服务器响应头,从服务器