繁体   English   中英

Angular iOS 文本字段焦点

[英]Angular iOS text field focus

当我打开带有输入的 div 时,我需要打开移动键盘。 我试图设置输入的焦点

 this.changeCityInput.nativeElement.focus();

当我单击父 div 时触发。 单击父 div 子扩展并显示输入字段后

但它在 ios 上不起作用,对于桌面和 android 它工作正常。

document.body.ontouchend = () => {
        this.changeCityInput.nativeElement.focus();
      };
setTimeout(() => {
  this.renderer.selectRootElement(this.changeCityInput.nativeElement).focus();

  this.changeCityInput.nativeElement.focus();
}, 500);

不工作。 将重点放在输入上的正确方法是什么?


UPD:在 MacOS 上正常工作

焦点()不适用于禁用按钮我模拟禁用操作

默认情况下,当我使用输入打开 div 时,我将注意力集中在它上面,完成后我使用 blur() 取消焦点

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM