我有两种按钮,一种是普通的html按钮,另一种是自定义按钮。我只能在普通按钮上使用onClick事件,但是在另一个按钮上却不起作用。 我所拥有的自定义按钮:
import React from 'react'
import './custom-button.styles.scss'
function CustomButton({children,isGoogleSignIn,...buttonProps}) {
return (
<button className={`${isGoogleSignIn? 'google-sign-in':''} custom-button`}>
{children}
</button>
)
}
export default CustomButton
我使用它的代码:
<button onClick={() => alert("Normal button")}>Click me</button>
<CustomButton onClick={() => alert("Custom button")}>Click me</CustomButton>