reactjs - "Redundant alt attribute. Screen-readers

我输入了 <img src= {'https://robohash.org/${id}?size=300x300'}alt="photo" />在我的 React js 文件上, 保存文件后,我在 GitBash 上收到一条错误消息,说,

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

然后我删除了 alt从代码中,我收到错误消息,

img elements must have an alt prop, either with meaningful text, or an empty string for decorative images jsx-a11y/alt-text

我该如何解决这个问题?

最佳答案

不同于单词“照片”和“图像”(或任何指定的自定义单词)的“东西”。

关于reactjs - "Redundant alt attribute. Screen-readers already announce ` img ` tags as an image."代码错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67448468/

相关文章:

javascript - 使 href 中带有哈希 (#) 的每个 anchor 标记都不可点击

python - Tensorflow Metal 插件已注册错误

r - 使用 gsub() 从 R 中的数组中提取数字

r - 使向量的所有元素都不同

javascript - 类型错误:无法在 React 项目中读取 null 的属性 'length

git - 如何在 git pull 之前预览更改

loops - 为什么内循环收集不返回结果?

r - 从数据框中的前一列中减去每一列

awk - Unix 提取两行之间的行并将它们存储在各自的文件中

kotlin - 如何获取数组 Kotlin 中特定值的大小