Button 可以设置 href

This commit is contained in:
liaoxuezhi 2019-05-23 16:40:35 +08:00
parent d324cce852
commit 7eb68649bd
1 changed files with 8 additions and 1 deletions

View File

@ -12,6 +12,7 @@ interface ButtonProps
extends React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> {
id?: string;
className?: string;
href?: string;
size?: 'xs' | 'sm' | 'md' | 'lg';
type: 'button' | 'reset' | 'submit';
level: string; // 'link' | 'primary' | 'secondary' | 'info' | 'success' | 'warning' | 'danger' | 'light' | 'dark' | 'default';
@ -44,7 +45,7 @@ export class Button extends React.Component<ButtonProps> {
};
renderButton() {
const {
let {
level,
size,
disabled,
@ -57,13 +58,19 @@ export class Button extends React.Component<ButtonProps> {
type,
active,
iconOnly,
href,
...rest
} = this.props;
if (href) {
Comp = 'a';
}
return (
<Comp
type={Comp === 'a' ? undefined : type}
{...pickEventsProps(rest)}
href={href}
className={cx(
`Button`,
{