【问题标题】:Override class of underlying React component覆盖底层 React 组件的类
【发布时间】:2017-08-03 14:35:49
【问题描述】:

我正在使用现有的 React 组件(即 Paginate),它本身使用了一些组件(即 Button)。目前,Button 组件将其类设置为在 css 文件中定义的“X”。当我使用 Paginate 组件时,我想覆盖“X”的属性。有没有办法做到这一点?

【问题讨论】:

    标签: css reactjs


    【解决方案1】:

    我没有使用过 react,但是你可以在分页组件周围粘贴一个父 div 并将 css 引用为 .parent .x { attributes }?

    或者,您可以提供自己的覆盖 CSS 文件,该文件在反应样式之后加载。

    .parent .x {
      /* news styles */
    }
    <div class="parent">
      <div class="paginate">
        <div class="x"> x </div>
      </div>
    </div>

    【讨论】:

    • 请注意,我无法修改组件(分页、按钮)的底层反应代码。
    • 您是否查看过 DOM 以查看是否有任何父项可以在您的 CSS 中挂钩?或者看看你是否可以在 react 之后加载自己的样式。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-05-06
    • 1970-01-01
    • 2021-02-20
    • 2020-09-30
    • 2021-04-25
    • 1970-01-01
    • 2018-02-28
    相关资源
    最近更新 更多