简体   繁体   English

ReactJS样式组件

[英]ReactJS style component

I'm new to reactjs and I made a component like this: 我是reactjs的新手,我制作了一个像这样的组件:

<Row>
    <Column className="col-8 noPadding">
          <Text value={this.props.description} />
    </Column>
    <Column className="col-4 text-right noPadding">
          <Text {...this.props} />
    </Column>
</Row>

This works fine for me but if I'm using this component (named Autosuggest) I can't style it. 这对我来说很好用,但是如果我使用此组件(名为Autosuggest),则无法设置其样式。 I made a .css file (which works on other components) but it doesn't affect my Autosuggest control: 我制作了一个.css文件(可在其他组件上使用),但是它不会影响我的Autosuggest控件:

<AutoSuggest className="marginTop" {...this.props.formControlProps} description="test" value="test" />

CSS: CSS:

    .marginTop{
    margin-top: 3rem;
}

There is no margin for the Autosuggest control. Autosuggest控件没有边距。 I tried to change the color but it doesn't work too. 我试图更改颜色,但是它也不起作用。 Is the only way to style it, if you apply the styles in the component class? 如果在组件类中应用样式,这是样式的唯一方法吗?

Its solved just added a new property and set the className of the hosting to the properties value. 解决的方法只是添加了一个新属性,并将托管的className设置为properties值。 Thanks 谢谢

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

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