无法通过LESS(ant.design)更改主按钮颜色

问题描述 投票:0回答:1

我已经使用了蚂蚁设计来获得主按钮样式,但是尝试用LESS更改它的背景颜色,并且由于某种原因没有任何效果,有人可能会遇到相同的问题或知道解决方案,我知道我可以轻松做到这一点通过执行style = {{background-color}}来实现,但是我不希望在应该使用LESS时编写额外的代码。我正在为所有tekst设置原色,并且效果很好

@btn-primary-bg: #1B2F55;

  <Button type='primary' onClick={this.handleSubmitEmail}>{submit}</Button>

antd.customize.less

enter image description here

css reactjs less
1个回答
0
投票
您必须访问antd的按钮类才能更改样式。

向按钮组件添加新的类名。

<Button type='primary' classname={'my-button'} onClick={this.handleSubmitEmail}>{submit}</Button>

然后,在LESS文件中,执行此操作,

.ant-btn.my-button{ background-color: 'red' }

© www.soinside.com 2019 - 2024. All rights reserved.