//修改数据表状态值
updateSelected: function (id, selected){
var openid = app.globalData.openid;
var token = app.globalData.userInfo.token;
var url = app.globalData.domain + "Cart/updateSelected";
var params = { id: id, selected:selected, openid: openid, token: token };
util.wxRequest(url, params, data => {
}, params, data => {
console.log(data);
console.log(data.selectAll);//显示undefine 但打印data有数据
console.log(data.msg);
//这里判断就无法操作
if (data.selectAll == 1){
this.setData({
checkAll: true
})
}else{
this.setData({
checkAll: false
})
}
}, params, data => { });
}
打印出data.selectAll 显示undefine, 但是打印出整体data却是有数据
{data: {…}, header: {…}, statusCode: 200, errMsg: "request:ok"}
data: {code: 200, msg: "修改成功", selectAll: 1}
errMsg: "request:ok"
header: {Date: "Wed, 04 Jul 2018 16:21:57 GMT", Server: "Apache", X-Powered-By: "PHP/5.6.30", Content-Length: "47", Keep-Alive: "timeout=5, max=99", …}
statusCode: 200__proto__: Object
遇到过类似的情况,我们当时的情况是后端返回的数据突然多了BOM头,json解析失败。至于你现在是不是这个问题就要你们自己去排查了。
也遇到过类似问题,Json字符串没有被解析,需要JSON.parse手动调整一下,不过没有发现具体导致的原因