Javascript 使用样式化组件使元素选项卡化
我希望人们能够通过tab“关注”我的div。到目前为止,我试过:Javascript 使用样式化组件使元素选项卡化,javascript,html,reactjs,styled-components,Javascript,Html,Reactjs,Styled Components,我希望人们能够通过tab“关注”我的div。到目前为止,我试过: const Div = styled.div.attrs({ tabindex: '0', })` margin: auto; width: 100%; max-width: 1200px; height: 320px; background: url(${({ rtl }) => determineUrl(rtl)}) no-repeat center; display: grid; gri
const Div = styled.div.attrs({
tabindex: '0',
})`
margin: auto;
width: 100%;
max-width: 1200px;
height: 320px;
background: url(${({ rtl }) => determineUrl(rtl)}) no-repeat center;
display: grid;
grid-template-columns: 100%;
grid-template-rows: 100%;
@media (min-width: ${resolutions.min.mobile}px) and (max-width: ${resolutions.max.mobile}px){
max-height: 240px;
}
`;
这是:
<Div tabindex={0}>...</Div>
。。。
以及
<Div tabindex={"0"}>...</Div>
。。。
这些都不起作用,想不出其他任何东西。
tabindex
在React中不是有效的属性名称,它应该是tabindex
,并且它只接受数字作为值,因此tabindex={0}
应该为您解决这个问题tabindex
在React中不是有效的属性名称,它应该是tabIndex
,并且只接受数字作为值,因此tabIndex={0}
应该可以帮您解决这个问题