bie*_*ier 6 reactjs eslint styled-components prettier
我的reactjs styledcomponent包含以下代码:
<a styling="link" onClick={() => this.gotoLink()}>
<SomeComponent />
</a>
Run Code Online (Sandbox Code Playgroud)
这很好用,但随行随地抱怨:
Static HTML elements with event handlers require a role.
Run Code Online (Sandbox Code Playgroud)
如何解决此错误?
Rao*_*Rao 11
就我而言,我使用了 aria-hidden="true" 所以我可以提交。
<i className="pwdicon" onClick={togglePasswordVisiblity} >
After I updated like below,
<i className="pwdicon" onClick={togglePasswordVisiblity} aria-hidden="true" >
My problem is resolved
Run Code Online (Sandbox Code Playgroud)
参考链接:https : //github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/click-events-have-key-events.md
Jer*_*me 9
您需要在标签中添加角色道具以避免此警告,例如按钮
<a role = "button" styling="link" onClick={() => this.gotoLink()}>
<SomeComponent />
</a>
Run Code Online (Sandbox Code Playgroud)
我猜这是因为锚标记中缺少HREF道具(不确定)
| 归档时间: |
|
| 查看次数: |
6900 次 |
| 最近记录: |