代码之家  ›  专栏  ›  技术社区  ›  Luke Schlangen

添加“文本”作为控件组件后,React通知eslint关联的控件错误

  •  1
  • Luke Schlangen  · 技术社区  · 6 年前

    我正在尝试添加 informed 将包打包到我的项目中,但在添加以下组件时,eslint出现错误:

        <Form id="intro-form">
          <label htmlFor="intro-name">
            First name:
            <Text field="name" id="intro-name" />
          </label>
          <button type="submit">Submit</button>
        </Form>
    

    我已经加了 Text 给我的 .eslintrc controlComponent 但我还是犯了个错误:

    eslint] Form label must have ALL of the following types of associated control: nesting, id (jsx-a11y/label-has-for)

    我猜这不是把这个加到我的 文件?

    {
        "rules": {
          "jsx-a11y/label-has-associated-control": [ 2, {
            "labelComponents": ["label"],
            "labelAttributes": ["htmlFor"],
            "controlComponents": ["Text"]
          }]
      },
        "parser": "babel-eslint",
        "extends": [
          "airbnb"
        ]
      }
    

    当我改变 文本 input 错误消失了,所以我觉得我误解了这是怎么回事。关于如何允许 文本 输入 ?

    0 回复  |  直到 6 年前