为什么即使指定的路径正确,React.js也不会从我的磁盘加载图像?



我是初学者。我在练习,然后被困在这里了。指定的路径正确,产品上的图像名称正确,但仍然显示错误消息。我附上了截图。如果有人能帮我解决这个问题,请告诉我。

ScreenshotScreenshoterrordisk

文件夹结构

import product1 from '../../images/product-1.jpg';
import product2 from '../../images/product-2.jpg';
import product3 from '../../images/product-3.jpg';
export const productData = [
{
img: product1,
alt: 'Game',
name: 'Assassians Creed- Valhalla',
desc: 'Assassins Creed Valhalla is a 2020 action role-playing video game developed by Ubisoft Montreal and published by Ubisoft.',
price: '3,444',
button: 'Add to cart'
},
{
img: product2,
alt: 'Game',
name: 'Cyber Punk- 2077',
desc: 'Cyberpunk 2077 is an action role-playing video game developed and published by CD Projekt.   ',
price: '2999',
button: 'Add to cart'
},
{
img: product3,
alt: 'Game',
name: 'Metro Exodus',
desc: 'Metro Exodus is a first-person shooter video game developed by 4A Games and published by Deep Silver.',
price: '2199',
button: 'Add to cart'
}
];````

您的代码data.js正在查找目录"../../images"中的文件,该文件在您的文件夹结构中不存在。真正存在的是&;…/…/images &;

将文件夹名称大写:

在图像;图片

最新更新