情况描述

console.log(res);

{data: "{
↵	"success":true,
↵  "data":[{
↵    "articleList…"sourceUrl":"http://jdc.jd.com/"
↵    }]
↵  }]
↵}", status: 200, statusText: "OK", headers: {…}, config: {…}, …}
headers: {date: "Sat, 07 Sep 2019 06:44:38 GMT", content-encoding: "gzip", last-modified: "Sat, 07 Sep 2019 06:31:35 GMT", x-powered-by: "Express", etag: "W/"1110-16d0a6bba8b"", …}
request: XMLHttpRequest {onreadystatechange: ƒ, readyState: 4, timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, …}
status: 200
statusText: "OK"
__proto__: Object

参考:

res.data.xxx undefined
关于前台获取到的后台json对象取值时undefined的解决方法


本次原因

在排除以上几种可能后,认真比对了json文件
原因竟是 我的内容太长 导致我没有发现 “…’ 的错误


总结

以后尽量避免出现长代码的情况
这个问题从出现到找到原因花了我大半天 orz
拒绝再次踏入此坑

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐