ReactJS没有采用css风格

Joh*_*n64 1 html javascript css reactjs reactjs.net

我可能会以错误的方式解决这个问题,但是可以在一个reactjs组件中添加样式和外部CSS文件吗?我试图用传统的方式做到这一点但是这似乎不起作用,你在外部css中引用类或id并在那里做你所有的样式.

    var ProfilePanel = React.createClass({
  render: function() {
    return (
      <div>
        <p class="profile-text">{this.props.text}{this.props.children}</p>    
      </div>
    );
  }
});
Run Code Online (Sandbox Code Playgroud)

在我的CSS中我有:

    .profile-text{
        font-size: 10px;
    }
Run Code Online (Sandbox Code Playgroud)

Hai*_*ude 6

你使用的class是js保留的.你需要使用className并且应该工作.

阅读更多