0


antd 中 如何改变按钮颜色,自定义样式颜色

只是做了简单的封装,欢迎指正

  1. import { Button } from 'antd';
  2. import React from 'react';
  3. import styles from './MyBtn.less';
  4. interface BtnPros {
  5. BtnName?: string;
  6. onClick?: React.MouseEventHandler<HTMLButtonElement>;
  7. children?: any;
  8. }
  9. export default ({ onClick, children }: BtnPros) => {
  10. let BtnName = '';
  11. React.Children.map(children, (child: any) => {
  12. if (typeof child === 'string') BtnName = child;
  13. });
  14. return (
  15. <>
  16. <Button className={styles.btn} onClick={onClick}>
  17. {BtnName}
  18. </Button>
  19. </>
  20. );
  21. };
  1. .btn {
  2. background-color: #f6a04d;
  3. color: #fff;
  4. &:hover {
  5. color: #f6a04d !important;
  6. border-color: #f59b4c !important;
  7. }
  8. }
  1. <MyBtn onClick={clickfun}>click</MyBtn>


本文转载自: https://blog.csdn.net/2201_75483179/article/details/140326164
版权归原作者 2201_75483179 所有, 如有侵权,请联系我们删除。

“antd 中 如何改变按钮颜色,自定义样式颜色”的评论:

还没有评论