在向 API 發(fā)出多個(gè)請(qǐng)求后,我promise.all()請(qǐng)求并發(fā)出另一個(gè)請(qǐng)求,堅(jiān)持上一個(gè)請(qǐng)求的一些屬性。這給了我:(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: {...} 是我想要的鍵值對(duì)。在底部的這個(gè)組件中,console.log()對(duì)象出現(xiàn)了,但隨后它在map()? 為什么會(huì)這樣,我該如何解決?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> );};
映射道具時(shí)在反應(yīng)中丟失鍵值對(duì)
阿波羅的戰(zhàn)車(chē)
2023-04-20 10:48:08