为什么即使指定的路径正确,React.js 也不能从我的磁盘加载图像?
Why won't React.js load the images from my disk even when the specified path is correct?
我是初学者。我正在练习并被困在这里。指定的路径是正确的,产品上的图像名称是正确的,仍然显示错误信息。我附上截图。如果有人可以帮助我解决这个问题,请告诉我。
ScreenshotScreenshoterrordisk
Folder structure
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”。
我是初学者。我正在练习并被困在这里。指定的路径是正确的,产品上的图像名称是正确的,仍然显示错误信息。我附上截图。如果有人可以帮助我解决这个问题,请告诉我。
ScreenshotScreenshoterrordisk
Folder structure
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”。