V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
longggg
V2EX  ›  React

react button bsClass 理解

  •  
  •   longggg · 2015-12-14 19:34:10 +08:00 · 2604 次点击
    这是一个创建于 3070 天前的主题,其中的信息可能已经有所发展或是发生改变。

    在使用 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 ,那么成熟一点的方案应该是什么,求各位大神不灵赐教,小弟初次发帖,求指导。

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3686 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 00:10 · PVG 08:10 · LAX 17:10 · JFK 20:10
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.