[英]Using aria attributes on elements in react
I have the following render method:我有以下渲染方法:
render: function () {
return (
React.createElement('div', {className: 'modal', id: 'errorModal', tabIndex: '-1', role: 'dialog', ariaHidden: 'true', dataBackdrop: 'false', style: {marginTop: '30px'}}, 'text')
)
}
That gives me error:这给了我错误:
react.js:20541 Warning: Unknown props
ariaHidden
,dataBackdrop
on tag. react.js:20541 警告:未知道具ariaHidden
,dataBackdrop
上的dataBackdrop
。 Remove these props from the element.从元素中删除这些道具。 For details, see in div (created by Constructor) in Constructor详情见Constructor中的div(由Constructor创建)
How could I solve this?我怎么能解决这个问题? Documentation says that I can use these attributes.文档说我可以使用这些属性。 Lowercase does not work either.小写也不起作用。 I don't want to use jsx.我不想使用 jsx。
Instead of camel case, use hyphens to define aria
attributes as described in React's docs :使用连字符来定义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')
)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.