警告:无效的DOM属性`tabindex`。您是说`tabIndex`吗?

时间:2019-12-26 12:14:47

标签: reactjs

我想在react中设置一个tabindex,从而给我一个警告:“警告:无效的DOM属性tabindex。您是说tabIndex吗?”

>

我的代码是:

<Nav.Item key={label}>
      <Nav.Link tabindex={index+1} > Test  </Nav.Link>
</Nav.Item>

当我使用tabIndex时,没有错误,但不起作用,而当我使用共享代码时,它却可以工作,但是发出警告,我想删除该警告。

2 个答案:

答案 0 :(得分:3)

reactjs中的属性遵循camelCase。因此,警告。 然后在Public Function Execute(cQry As excfw_dbQuery) As ADODB.Recordset If pConn.State = 0 Then OpenConnection End If qry = "INSERT INTO [some really long query, which actually works]; SELECT SCOPE_IDENTITY()" On Error Resume Next Dim rs As ADODB.Recordset Set rs = New ADODB.Recordset rs.Open cQry.Query, pConn, adOpenKeyset, adLockOptimistic 'some error handling code which is not related to the issue On Error Resume Next 'begin loop Do 'go to next recordset Set rs = rs.NextRecordset() 'if we're getting error n. 91, it means 'recordsets are exhausted, hence we're getting 'out of the loop If Err.Number = 91 Then Err.Clear Exit Do End If 'if we are not out of recordsets, check the 'result of the query. If it is bigger then zero, 'it means we hit the jackpot. If rs.Fields(0).Value > 0 Then pInsertedId = rs.Fields(0).Value End If Loop On Error GoTo 0 End Function >中使用tabIndex代替<Nav.Item

<Nav.Link>

签出https://codesandbox.io/s/billowing-sun-n969i

<Nav.Item key={label} tabIndex=`${index+1}` > <Nav.Link> Test </Nav.Link> </Nav.Item> tabIndex一起使用时,效果很好

答案 1 :(得分:0)

Official React docs says

  

在React中,所有DOM属性和属性(包括事件处理程序)都应被驼峰化。例如,HTML属性tabindex对应于React中的属性tabIndex。 aria- *和data- *属性是例外,应将其小写。例如,您可以将aria-label保留为aria-label。

React中的所有DOM属性都应该在camelCase中。例如,

className="btn btn-primary"而不是classname="btn btn-primary"

在您的情况下,应严格使用tabIndex而不是tabindex

相关问题