我遇到了这种类型错误。没有重载与此调用匹配。
重载第 1 个(共 3 个)“(props: PolymorphicComponentProps<"web", FastOmit
下面是我的代码...
type ButtonProps = {
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void; // to handle onClick functions
children?: React.ReactNode; // make the component able to receive children elements
color?: 'primary' | 'secondary'; // two styling options (you can create as many as you want)
disabled?: boolean; // make the button disabled or not
href?: string;
};
const Button = ({href, children}: ButtonProps) =>{
return(
<BtnSection>
<SignInBtn href={href} >{children}</SignInBtn>
<Icon src={icon} width="24" height="24"/>
</BtnSection>
)
}
我尝试通过将 href 作为道具传递来使我的按钮可重用
因此,经过多次尝试,我能够通过删除 href propytype 声明中的问号来解决问题
href?: string;
现在我用这个,
href: string;