在这个简单的函数中,data.images 显示未定义,但我知道它不为空,当我 console.log(data) 图像数组显示在控制台上时,请帮忙......
import { results } from "../../product"
export default function FetchProduct(products) {
const productsDetailArray = () => {
const temp = []
for (let i = 0; i < products.length; i++) {
const productId = products[i].productId
console.log(products[i])
const data = results.filter((item) => item.id === productId)
console.log(data.images)
temp.push({
count: products[i].count,
product: { ...data, images: [...data.images] },
})
}
return temp
}
return productsDetailArray()
}
const data = results.filter((item) => item.id === ProductId) data 是数组,这意味着它应该是 产品:{ ...数据[0],图像:[...数据[0].图像] },