React 不会加载图片

时间:2021-02-22 23:04:23

标签: reactjs image load

我正在构建一个 React 博客,但我的图片无法加载。它在控制台中向我显示此消息 - src\components\BlogPost\index.js

src/test/resources/application-test.yml

我的来源:

  Line 21:11:  Redundant alt attribute. Screen-readers already announce `img` tags as an image. You don’t need to use the words `image`, `photo,` or `picture` (or any specified custom words) in the alt prop  jsx-a11y/img-redundant-alt. 

请帮忙。谢谢。

2 个答案:

答案 0 :(得分:0)

<img src="example" aria-hidden alt="Picture of me taking a photo of an image" /> 

添加“咏叹调隐藏”

答案 1 :(得分:0)

  1. 冗余 alt 属性 警告不会阻止图像加载。这意味着您的图像中有一个无意义的 alt。 alt 属性对于可访问性很有用,并且必须在下载失败时描述图像。

对图片使用准确的描述,或对背景和装饰使用 alt=""

  1. 加载错误可能是由导入错误引起的。检查图像路径、名称和位置。 这是图像导入的示例。
import logo from '../static/logo.png';

export default function Navbar() {
  return (
    <img src={logo} alt='website logo' />
  )
}