【发布时间】:2020-08-06 18:03:46
【问题描述】:
我正在尝试使用以下代码加载存储在我的数据库文件夹中的图像:
<Carousel autoplay>
{props.images.map((image, index) => (
<div key={index}>
<img style={{ width: '100%', maxHeight: '150px' }}
src={`http://localhost:5000/${image}`} alt="productImage" />
</div>
))}
</Carousel>
</div>
但我收到此错误: error
存储在数据库中的图像是这样的:
{
"images": [
"uploads\\1596557942509_discount.png"
],
"categories": 3,
"_id": "5f298a8f205d0e109c896979",
"productname": "Justchecking",
"price": "444",
"shopadress": "Checking",
"contactdetails": "9999999",
"createdAt": "2020-08-04T16:19:27.168Z",
"updatedAt": "2020-08-04T16:19:27.168Z",
"__v": 0
},
【问题讨论】:
-
你是如何获取你的数组的?