小编Anu*_*Anu的帖子

“冗余 alt 属性。屏幕阅读器已经将‘img’标签宣布为图像。” 代码错误

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

\n

Redundant alt attribute. Screen-readers already announce 'img' tags as an image. You don\xe2\x80\x99t need to use the words 'image', 'photo,' or 'picture' (or any specified custom words) in the alt prop jsx-a11y/img-redundant-alt

\n

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

\n

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

\n

我该如何解决这个问题?

\n

compiler-warnings reactjs

2
推荐指数
2
解决办法
2万
查看次数

标签 统计

compiler-warnings ×1

reactjs ×1