在反应中使用元素的aria属性

use*_*999 3 javascript reactjs

我有以下渲染方法:

render: function () {
  return (
    React.createElement('div', {className: 'modal', id: 'errorModal', tabIndex: '-1', role: 'dialog', ariaHidden: 'true', dataBackdrop: 'false', style: {marginTop: '30px'}}, 'text')
  )
}
Run Code Online (Sandbox Code Playgroud)

这给了我错误:

react.js:20541警告:未知的道具ariaHidden,dataBackdrop在标签.从元素中删除这些道具.有关详细信息,请参阅构造函数中的div(由Constructor创建)

我该怎么解决这个问题?文档说我可以使用这些属性.小写也不起作用.我不想使用jsx.

Tim*_*imo 8

而不是驼峰案例,使用连字符来定义aria属性,如React的文档中所述:

render: function () {
  return (
    React.createElement('div', {className: 'modal', id: 'errorModal', tabIndex: '-1', role: 'dialog', 'aria-hidden': 'true', dataBackdrop: 'false', style: {marginTop: '30px'}}, 'text')
  )
}
Run Code Online (Sandbox Code Playgroud)