Html 样式化组件按钮href/onclick不工作
我正在学习JS/尝试使用gatsby创建一个网站,需要使用按钮,并且一直在使用样式化组件 按钮会显示出来,当我在上面悬停时,它会变成黄色,但是当我悬停或单击按钮打开谷歌时,我没有抓取鼠标 请帮忙:) 我尝试只使用href属性,就像在主网站上使用的一样Html 样式化组件按钮href/onclick不工作,html,css,reactjs,gatsby,styled-components,Html,Css,Reactjs,Gatsby,Styled Components,我正在学习JS/尝试使用gatsby创建一个网站,需要使用按钮,并且一直在使用样式化组件 按钮会显示出来,当我在上面悬停时,它会变成黄色,但是当我悬停或单击按钮打开谷歌时,我没有抓取鼠标 请帮忙:) 我尝试只使用href属性,就像在主网站上使用的一样 <Button href="https://github.com/styled-components/styled-components" target="_blank" rel="noopener"
<Button
href="https://github.com/styled-components/styled-components"
target="_blank"
rel="noopener"
primary
>
这是令人不快的代码
<button onclick="window.open('https://www.google.com', '_blank');"> work</button>
<Button click={() => 'https://www.google.com';}}>pleaseWork </Button>
工作
'https://www.google.com';}}>愉快的工作
您应该添加样式化.a
非样式化.button
以访问href
属性
现在,您可以添加样式化组件,如网站:
<Button
href="https://github.com/styled-components/styled-components"
target="_blank"
rel="noopener"
primary
>
按钮没有href属性。你需要使用锚定标签
<Button
href="https://github.com/styled-components/styled-components"
target="_blank"
rel="noopener"
primary
>