简体   繁体   English

ReactJS没有选择CSS样式

[英]ReactJS not picking up css style

I am probably going about this the wrong way, but is it possible to add styles from and external CSS file within aa reactjs component? 我可能会以错误的方式进行操作,但是是否可以在reactjs组件中从外部CSS文件添加样式? I have tried to do it the conventional way however this does not seem to work, where you reference the class or id within the external css and do all your styling there. 我尝试以常规方式执行此操作,但是这似乎不起作用,您需要在外部CSS中引用类或id并在那里进行所有样式设置。

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

and within my CSS I have: 在我的CSS中,我有:

    .profile-text{
        font-size: 10px;
    }

You're using class which is reserved by js. 您正在使用js保留的class You need to use className and should work. 您需要使用className并且应该可以工作。

Read more 阅读更多

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM