[英]ReactJS style component
我是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>
這對我來說很好用,但是如果我使用此組件(名為Autosuggest),則無法設置其樣式。 我制作了一個.css文件(可在其他組件上使用),但是它不會影響我的Autosuggest控件:
<AutoSuggest className="marginTop" {...this.props.formControlProps} description="test" value="test" />
CSS:
.marginTop{
margin-top: 3rem;
}
Autosuggest控件沒有邊距。 我試圖更改顏色,但是它也不起作用。 如果在組件類中應用樣式,這是樣式的唯一方法嗎?
解決的方法只是添加了一個新屬性,並將托管的className設置為properties值。 謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.