我有以下代码:

Enabled = (id) => {
  let removal = null;
  if (!this.props.disabled) {
    removal = (
      <span
        className="chipRemove"
        onClick={() => this.onDelete(id)}
      >
        x
      </span>)
    ;
  }
  return removal;
}

它运作良好,但是lint给了我:
jsx-a11y/no-static-element-interactions

如何解决此错误(根据jsx-a11y)?

最佳答案

从文档:



有效的交互元素是:

<a> elements with href or tabIndex props
<button> elements
<input> elements that are not hidden
<select> and <option> elements
<textarea> elements
<area> elements

引用:https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-static-element-interactions.md

关于javascript - 静态元素相互作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42225468/

10-12 15:50