2016-08-17 67 views
2

我有以下渲染方法:使用ARIA属性

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

这给了我错误:

react.js:20541 Warning: Unknown props ariaHidden , dataBackdrop on tag. Remove these props from the element. For details, see in div (created by Constructor) in Constructor

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

+2

试''咏叹调-hidden''代替'ariaHidden' –

+0

同样使用'数据backdrop'代替'dataBackdrop '。数据属性必须以React的'data-'前缀开始传递。 –

+0

对于React发出对复合支柱名称的警告似乎是不礼貌的,并且在其他情况下警告反对骆驼套的道具名称!为什么不一致,需要ariaHidden等? – pwray

回答

6

代替骆驼情况下,使用连字符来定义aria属性描述in React's docs

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

https://facebook.github.io/react/docs/dom-elements.html – primavera133

相关问题