反应JS标签和属性

时间:2016-10-21 04:41:51

标签: reactjs

如何使div属性React友好?

 <div className="section-modal modal fade" id="pricing-modal" tabindex="-1" role="dialog" aria-hidden="true">

 </div>

我试过:

 <div className="section-modal modal fade" id="service-modal" tabindex= {-1} role={dialog} aria-hidden={true}>

2 个答案:

答案 0 :(得分:1)

字符串应括在引号,bool,数字,变量和括号中的对象中。在你的情况下应该是:

 <div className="section-modal modal fade" id="service-modal" tabindex={-1} role="dialog" aria-hidden={true}>

在此处阅读有关jsx的更多信息:

https://facebook.github.io/react/docs/jsx-gotchas.html

答案 1 :(得分:0)

CamelCase是HTML中的问题

您应该参考https://facebook.github.io/react/docs/tags-and-attributes.html#html-attributes

React仅支持列表中给出的一组HTML属性,而忽略其余的属性。除数据 - 咏叹调 - 外,所有属性都应 camelcased 。你的HTML应该是这样的。

<div className="section-modal modal fade" id="pricing-modal" tabIndex="-1" role="dialog" aria-hidden="true">

 </div>
相关问题