很多人写着React,随着业务变多,会有需求设置inline style:
- React里面,style不能写成string,而是定义为对象
- 对象的key是camelCased的style name
var divStyle = {
color: 'white',
WebkitTransition: 'all'
}
React.renderComponent(<div style={divStyle}>Hello</div>)
本文介绍了如何在React中使用内联样式。不同于传统的字符串形式,React要求将样式定义为对象,并采用camelCase来命名属性。文章通过示例展示了如何创建并应用这样的样式。
很多人写着React,随着业务变多,会有需求设置inline style:
var divStyle = {
color: 'white',
WebkitTransition: 'all'
}
React.renderComponent(<div style={divStyle}>Hello</div>)

被折叠的 条评论
为什么被折叠?