首页 > 解决方案 > 为什么即使指定的路径正确,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'
  }

];````



标签: javascriptreactjsreact-hooksfrontendweb-deployment

解决方案


在导入中将您的文件夹名称大写:

图片 > 图片


推荐阅读