在向 API 发出多个请求后,我promise.all()请求并发出另一个请求,坚持上一个请求的一些属性。这给了我:
(4) [{…}, {…}, {…}, {…}]
0: {product_id: "2", results: Array(4), productInfo: {…}}
1: {product_id: "3", results: Array(6), productInfo: {…}}
2: {product_id: "8", results: Array(9), productInfo: {…}}
3: {product_id: "7", results: Array(5), productInfo: {…}}
length: 4
__proto__: Array(0)
这productInfo: {...} 是我想要的键值对。在底部的这个组件中,console.log()对象出现了,但随后它在map()? 为什么会这样,我该如何解决?
const FormatRelated = ({ recommended }) => {
// eslint-disable-next-line no-console
console.log(recommended)
return (
<div className="recommendedThumbNailsRow">
{recommended.map(obj => {
// eslint-disable-next-line no-console
console.log(obj);
return <DisplayRelatedImg styles={obj} />;
})}
</div>
);
};
冉冉说
相关分类