【发布时间】:2022-01-02 00:27:46
【问题描述】:
我尝试使用 itemDate.js 文件显示我的图片:
const itemData = [
{
img: "../assets/photos/photoportrait.jpeg",
title: 'Breakfast',
},
并使用我的投资组合组件调用:
import * as React from 'react';
import ImageList from '@mui/material/ImageList';
import ImageListItem from '@mui/material/ImageListItem';
import itemData from './itemData';
function Portfolio() {
return(
<ImageList sx={{ width: 500, height: 450 }} cols={3} rowHeight={164}>
{itemData.map((item) => (
<ImageListItem key={item.img}>
<img
src={item.img}
srcSet={item.img}
alt={item.title}
loading="lazy"
/>
</ImageListItem>
))}
</ImageList>
没有错误消息,路径是正确的,但我的页面上没有出现任何内容。它适用于链接,但不适用于本地路径。有什么想法吗?
谢谢
【问题讨论】:
标签: arrays reactjs image material-ui