react button bsClass 理解

2015-12-14 19:34:10 +08:00
 longggg

在使用 react 的 bootstrap button 时看到如下这段文档:

bsClass string 'btn'

Base css class name and prefix for the Component. Generally one should only change bsClass if they are providing new, non bootstrap, css styles for a component.

本人英语比较渣,个人理解上面这段话的意思是:组建的基础 css 类名累和前缀。通常,如果你为组建提供的是新的,不在 bootstrap 的 css styles ,那么你只应该修改 bsClass 。

而我在自己的项目中这样使用
<Bootstrap.Button bsClass="user-remark" bsStyle="btn-link">{this.props.note}</Bootstrap.Button>

然后在自定义的 css 文件中对 user-remark 进行了装饰。
但是,当我测试这个页面时, console 出现 warning :
Warning: Failed propType: Invalid prop 'bsClass' of value 'user-remark' supplied to 'Button', expected one of ["alert","button","button-group","button-toolbar","column","input-group","form","glyphicon","label","thumbnail","list-group-item","panel","panel-group","pagination","progress-bar","nav","navbar","modal","row","well"]. Check the render method of TestView.

当然,我能读懂这段 warning ,说的是 bsClass 应该使用提供的选项中拥有的属性。 那么,最上面的 Generally one should only change bsClass if they are providing new, non bootstrap, css styles for a component.是什么意思啊?或者说怎么用?我的理解有误?

ps :我知道 react 不建议自己手写 css ,那么成熟一点的方案应该是什么,求各位大神不灵赐教,小弟初次发帖,求指导。

2613 次点击
所在节点    React
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/243525

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX