diff --git a/src/components/action/Action.tsx b/src/components/action/Action.tsx index 0bc3477..af949db 100644 --- a/src/components/action/Action.tsx +++ b/src/components/action/Action.tsx @@ -2,23 +2,27 @@ import { Button, ButtonProps } from 'antd' import { useStyle } from './style' export interface ActionProps extends ButtonProps { - as?: string + as?: string } const Action = ({ title, as, children, ...props }: ActionProps) => { - const { styles } = useStyle() + const { styles } = useStyle() - const isLink = as === 'a' || props.type === 'link' - //fixme 如果外部同时设置 as={'a'} disabled={true} ,这里a标签会置灰,但是仍可点击,为什么不直接用Button? - const Comp = isLink ? 'a' : Button - return ( - + const isLink = as === 'a' || props.type === 'link' + const Comp = isLink ? 'a' : Button + return ( + {title ?? children} + onClick={(e) => { + if (props.onClick && !props.disabled) { + props.onClick(e) + } + }} + type={isLink ? 'link' : props.type} + className={as === 'a' ? styles.actionA : ''}>{title ?? children} - ) + ) } export default Action \ No newline at end of file