- 服务器端封装的业务数据data为
"data": {
"code": "0",
"msg": "success",
"res": {
"token": "WM8JngVEeUi6sQmK",
"receive": {
"username": "**",
"password": "**",
"timestamp": "1562641227000"
}
}
},
- h5端获取data数据为
{
"code": "0",
"msg": "success",
"res": {
"token": "GY23kxVhKmkwxXRy",
"receive": {
"username": "**",
"password": "**",
"timestamp": "1562641227000"
}
}
}
响应头.png
备注
:若遇到跨域问题,可参考uni-app之浏览器跨域问题解决方案来解决,主要是服务器端进行设置从而允许跨域请求。跨域.png
- app端获取数据为
{
"data": "200 OK",
"statusCode": 200,
"header": {
"X-Android-Sent-Millis ": "1562634044102",
"Content-Type ": "application/json;charset=utf-8;",
"Date ": "Tue, 09 Jul 2019 01:00:44 GMT",
"Server ": "nginx/1.14.0",
"X-Android-Response-Source ": "NETWORK 200",
"X-Android-Received-Millis ": "1562634044133",
"Access-Control-Allow-Origin ": "*",
"Cache-Control ": "no-store, no-cache, must-revalidate",
"Pragma ": "no-cache",
"Expires ": "Thu, 19 Nov 1981 08:52:00 GMT",
"X-Powered-By ": "PHP/7.1.16",
"Transfer-Encoding ": "chunked",
"Connection ": "keep-alive"
},
"errMsg": "request:ok"
}
分析
:app端data中无业务数据;但是响应头与h5端相比多了3个android相关的参数,即X-Android-Sent-Millis
、X-Android-Response-Source
和X-Android-Received-Millis
。
解决
:修改该uni-app项目的配置文件mainfest.json,选择App常用其他设置,自定义组件模式默认是开启的,关闭自定义组件模式
并重启开发工具
即解决app端请求数据中无业务数据的问题,此时app端获取到的响应头的参数与h5端是一样的。
备注
:uni-app新老编译模式差异说明app端请求获取的完整数据为:
{
"data": {
"code": "0",
"msg": "success",
"res": {
"token": "N6iXKWHEc_DmFJ2k",
"receive": {
"username": "**",
"password": "**",
"timestamp": "1562641227000"
}
}
},
"statusCode": 200,
"header": {
"Pragma": "no-cache",
"Date": "Tue, 09 Jul 2019 04:50:42 GMT",
"Server": "nginx/1.14.0",
"X-Powered-By": "PHP/7.1.16",
"Transfer-Encoding": "chunked",
"Content-Type": "application/json;charset=utf-8;",
"Access-Control-Allow-Origin": "*",
"Cache-Control": "no-store, no-cache, must-revalidate",
"Connection": "keep-alive",
"Expires": "Thu, 19 Nov 1981 08:52:00 GMT"
},
"errMsg": "request:ok"
}
其他
:h5端调试时,若页面出现your connention is not peivate
问题,点击页面的Advanced
暂时解决(实际是中病毒了,可安装火绒安全软件进行杀毒)。
网友评论