【发布时间】:2018-11-06 06:51:47
【问题描述】:
我需要使图像标签可点击,但我收到 jsx-a11y 的警告,我该如何修复它,我已经阅读了no-noninteractive-element-interactions,但我不想将其他 div 标签包装在 img 标签周围,因为它会使一个冗余标签,还有其他方法可以解决这个警告吗?
警告是[eslint] Non-interactive elements should not be assigned interactive roles.
我的代码是
<img
styleName="pic-id-code"
src={picCodeImgSrc}
alt="pic id code"
onClick={this.refreshPicCodeImg}
onKeyPress={this.handleKeyPress}
role="button"
tabIndex="0"
/>
【问题讨论】: