我在我的React js文件中输入了<img src= {'https://robohash.org/${id}?size=300x300'}alt="photo" />,在我保存了该文件之后,我在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
我如何解决这个问题?
发布于 2021-05-08 22:22:44
我试过这个方法,它起作用了:
<input type="image" img src = {'https://robohash.org/${id}?size=300x300'} alt="photo" />
(我使用的是,而不是url的单引号)
发布于 2021-07-08 03:35:03
https://robohash.org/${id}?size=300x300'}alt="something“/>
“一些东西”不同于单词“照片”和“图像”(或任何指定的自定义单词)。
https://stackoverflow.com/questions/67448468
复制相似问题