Tab
可以很容易地在forficialdemo中看到,或者通过使用此信息很容易看到
CodeSandbox
:
我在平原上经历了某些问题,例如tabindex -1不适用于儿童元素
如何使一堆无法从键盘访问,许多元素使用
JS
或visibility: hidden
建议。 。但是,我想知道是否有方法可以防止其他组件访问,但仍然可见。
您可以尝试使用
display: none
风格。
pointer-events: none;
属性与
open
一起用作元素是否应无法访问的指标。
有两种方法可以实现所需的效果 - 允许可见元素,但通过mouse
.可见。
最简单的方法是使用
keyboard
tabIndex="-1"
// ...other JS codes
return (
{/* ...other HTML codes */}
<div>
<div>
<button tabIndex={open ? -1 : 0}>Button A</button>
</div>
<div>
<button tabIndex={open ? -1 : 0}>Button B</button>
</div>
<div>
<button tabIndex={open ? -1 : 0}>Button C</button>
</div>
</div>
);
。
inert
对于那些与// ...other JS codes
return (
{/* ...other HTML codes */}
<div inert={open}>
<div>
<button>Button A</button>
</div>
<div>
<button>Button B</button>
</div>
<div>
<button>Button C</button>
</div>
</div>
);
一起使用React
的人,请检查以下问题:
使用`inert'属性与typescript.。