javascript - 为什么即使指定的路径正确,React.js 也不会从我的磁盘加载图像?
问题描述
我是初学者。我正在练习并被困在这里。指定的路径是正确的,产品上的图像名称是正确的,但仍然显示错误消息。我附上截图。请让我知道是否有人可以帮助我解决这个问题。
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'
}
];````
解决方案
在导入中将您的文件夹名称大写:
图片 > 图片
推荐阅读
- python - Python,将html表转换为数据框
- javascript - 当我使用 javascript 获取数据时,请求的 URI 太大
- python - kivy 没有名称为“main_screen”的屏幕
- asynchronous - Task.Delay(-1) 的 F# 等价物是什么?
- flutter - Flutter - 如何将收据打印到蓝牙打印机?
- angular - 订阅完成后 Angular 调用函数
- node.js - 如何使用`tsc`和`npm install`解决鸡/蛋情况?
- python - 提高python中重复代码的效率
- python - 如何从python原始套接字中的传入数据包中获取消息
- java - 在 Spring Boot 中序列化行 JSON 的最佳方法