前几天在做前后端数据交互的时候,遇到了这个问题:
Failed to load resource: net::ERR_CONNECTION_REFUSED
Uncaught (in promise) Error: Network Error
Failed to load resource: the server responded with a status of 404 (Not Found) — 加载资源失败
排查了好几个可能的问题,但是都不对症,最后才发现是最简单的问题:
我在前端获取数据的时候,写的是
that.productVersions = resp.data;
而这句代码的意思是获取到数据本身,并不是获取到具体的数据,resp.data(resp为axios自定义的对象)只获取到浏览器自带的第一层,应该是这么写:
that.productVersions = resp.data.data;
这样才是获取到第二层具体的data