加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

reactjs – 如何自定义react-bootstrap组件?

发布时间:2020-12-15 05:05:54 所属栏目:百科 来源:网络整理
导读:覆盖css类/自定义react-bootstrap组件的最佳方法是什么? – (我已经阅读过文档,除非我遗漏了一些内容,否则不予考虑). 从我所看到的,它似乎是内联样式(镭)和CSS模块之间的选择,但哪个更好,为什么? 我不确定这是否能回答您的问题,但 Documentation明确提供了
覆盖css类/自定义react-bootstrap组件的最佳方法是什么? – (我已经阅读过文档,除非我遗漏了一些内容,否则不予考虑).

从我所看到的,它似乎是内联样式(镭)和CSS模块之间的选择,但哪个更好,为什么?

我不确定这是否能回答您的问题,但 Documentation明确提供了示例.例如 Button

道具

+--------+---------+--------+--------------------------------------------+
|  Name  |  Type   | Default| Description                                |
+--------+---------+--------+--------------------------------------------+
|bsClass |  string | 'btn'  | Base CSS class and prefix for the component|
+--------+---------+--------+--------------------------------------------+

可以修改此选项以将自定义CSS类添加到Button组件.也可以通过设置componentClass来更改组件.

<Button type="submit" onClick={this.submit}
 bsClass='custom-class'
>
</Button>

custom-class是CSS类,可以

provide new,non-Bootstrap,CSS styles for a component.

Fiddle以及如何使用bsClass的示例.

内联样式:

根据bug填充,内联样式将不会正式支持.

you want to use the actual style prop. bsClass is for adjusting the
way bootstrap css classes are applied to the components not inline
styles

但issue指出:

You’re free to use them if you want. We have no formal opinion.

注意并非react-bootstrap提供的所有组件都允许通过bsClass进行类自定义,例如Breadcrumb

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读