gpt4 book ai didi

Angular4向导第一个文本字段专注于下一步

转载 作者:行者123 更新时间:2023-12-02 15:23:20 25 4
gpt4 key购买 nike

我开发了基于 Angular4 的向导,在我有表单的每一步中,在我想要关注第一个文本字段的步骤之间切换,我能够通过 html 属性 autofocus 关注第一步但仅当页面加载时,当我在步骤之间切换时无法获得焦点。

尝试了以下示例,但不幸的是没有成功,

Is there an Angular2 way to focus on an input field?

plunker 上创建了一个示例

最佳答案

我已成功使用上面链接中描述的方法 ( Is there an Angular2 way to focus on an input field? ),但我必须将对 focus() 的调用放入 setTimeout():

setTimeout(() => {
(<HTMLInputElement> this.myInputField.nativeElement).focus();
}, 250);

关于Angular4向导第一个文本字段专注于下一步,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49735756/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com