https://stackblitz.com/edit/react-cuaaqu?file=demo.tsx,index.css
在全局 CSS 中指定链接 a 的颜色(实际应用中,这部分是站点全局样式引入的,应用开发者无法控制):
a:link {
color: blue;
}
然后写一个带 href 的 Button:
<Button href="#">按钮</Button>
按钮文字颜色不应该被影响。
按钮文字颜色被影响,变成了蓝色。
Environment | Info |
---|---|
antd | 5.12.1 |
React | 18.2.0 |
System | maOS |
Browser | Chrome 121 |
主要原因还是 .btn-default 的 selector 就是单纯的 .ant-btn-default 而不是 .ant-btn.ant-btn-default,通过增加 selector 优先级即可解决。
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too