【问题标题】:Styling related components in ant designant design 中相关组件的样式化
【发布时间】:2020-09-13 16:05:29
【问题描述】:

我可以通过简单地用 styled 包装它来设置 antd 复选框组件的样式。

import { Checkbox } from 'antd';
const StyledCheckbox = styled(Checkbox)`...`

但是,当我想渲染一些衍生的东西时,比如Checkbox.Group, 当我使用 StyledCheckbox.Group

时,所有样式都会中断

样式化版本不再包含 group 属性。

有没有办法克服这个问题?

【问题讨论】:

    标签: antd styled-components ant-design-pro


    【解决方案1】:

    有办法克服吗?

    我不这么认为。我认为您应该创建两个共享共同样式的样式组件:

    import styled, { css } from 'styled-components';
    
    const commonStyle = css`
      ...
    `;
    
    const StyledCheckbox = styled(Checkbox)`
      ${commonStyle}
    `;
    
    const StyledCheckboxGroup = styled(Checkbox.Group)`
      ${commonStyle}
    `;
    

    【讨论】:

      猜你喜欢
      • 2019-03-13
      • 1970-01-01
      • 2018-09-05
      • 1970-01-01
      • 2020-03-19
      • 2020-02-17
      • 1970-01-01
      • 2019-03-09
      • 2019-02-18
      相关资源
      最近更新 更多