0

我用 dva 初始化了我的项目

// component.js
import React from 'react';
import { Table, Icon } from 'antd';
import styles from '../../style/public.less';
import comStyle from '../../style/company.less';

// company.less
.ant-table {
    border: none!important;
}

我的风格像这样“模块化”了ant-table-small___2ihaB 如何覆盖内置类?

4

1 回答 1

0

最后,一位同事帮我解决了这个问题——这个答案是:global,这将覆盖全局的内置样式。像这样:

:global {
  .ant-table {
    border: none;
  }
}

如果您不想全局覆盖它,只需嵌套:global在您的类中,然后将该类提供给您要设置样式的组件。

例子:

// myStyle.less
.myClass {
  :global {
    .ant-table {
      border: none;
    }
  }
}
// myComponent.js
<Table className={styles.myClass} />
于 2017-06-30T06:37:12.557 回答