Browse Source

修正Action为A标签时且disabled, onClick事件还能点击

main
dark 3 months ago
parent
commit
403cc7e113
  1. 6
      src/components/action/Action.tsx

6
src/components/action/Action.tsx

@ -10,11 +10,15 @@ const Action = ({ title, as, children, ...props }: ActionProps) => {
const { styles } = useStyle()
const isLink = as === 'a' || props.type === 'link'
//fixme 如果外部同时设置 as={'a'} disabled={true} ,这里a标签会置灰,但是仍可点击,为什么不直接用Button?
const Comp = isLink ? 'a' : Button
return (
<span className={styles.container}>
<Comp {...props}
onClick={(e) => {
if (props.onClick && !props.disabled) {
props.onClick(e)
}
}}
type={isLink ? 'link' : props.type}
className={as === 'a' ? styles.actionA : ''}>{title ?? children}</Comp>
</span>

Loading…
Cancel
Save