【发布时间】:2020-08-10 21:05:30
【问题描述】:
当我打开带有输入的 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);
不起作用。 将焦点设置在输入上的正确方法是什么?
更新: 在 MacOS 上正常工作
【问题讨论】:
标签: javascript angular