[英]How is it possible to use the tab key to navigate between different child components in the same page with Angular?
For accessibility reasons, all components but be navigable with the tab key.出于可访问性的原因,所有组件都可以使用 tab 键导航。 I have two components on a login page but the tab won't take the focus from the component above to the one below.
我在登录页面上有两个组件,但选项卡不会将焦点从上面的组件转移到下面的组件。
<div class="content">
<login-form
[formBuilder]="fb"
[submitting]="loginPageState.submitting"
></login-form>
<div
*ngIf="pageData.appSettings"
class="login-page__link"
[innerHtml]="pageData.appSettings.login_page_link | safe: 'html'"
></div>
<login-identity
(identity)="onIdentity($event)">
</login-identity>
</div>
Try to add tabindex attribute to your component: https://developer.mozilla.org/fr/docs/Web/HTML/Global_attributes/tabindex尝试将 tabindex 属性添加到您的组件: https://developer.mozilla.org/fr/docs/Web/HTML/Global_attributes/tabindex
For your component can use like this:对于您的组件,可以这样使用:
<login-identity
tabindex=3
(identity)="onIdentity($event)">
</login-identity>
Or like: in your component ts file:或者像:在您的组件 ts 文件中:
@Component({
selector: 'login-identity',
...
host: {
'tabindex': 3
},
})
export class LoginIdentityComponent
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.