Angular 2如何在按钮返回时模糊输入? [英] Angular 2 How to blur input on button return?
本文介绍了Angular 2如何在按钮返回时模糊输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何通过在移动设备上按本机键盘返回键button
来模糊input
?
How to blur input
by pressing native keyboard return button
on mobile ?
例如:
<input type="text" #search>
this.search.blur() //-- unfocus and hide keyboard
推荐答案
html文件
<input type="text" #search (keyup.enter)="doSomething()">
.ts文件
import { Component, ViewChild, ElementRef} from '@angular/core';
@ViewChild('search') search: ElementRef;
doSomething(): void {
this.search.nativeElement.blur()
}
正在工作 stackblitz
这篇关于Angular 2如何在按钮返回时模糊输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文