internet-explorer - ngx-bootstrap 字体自动专注于 Internet Explorer 11
问题描述
我正在使用 ngx-bootstrap 字体头和 Angular 6 反应形式控制。它在除 Internet Explorer 11 之外的所有浏览器上都可以正常工作。每当没有选择打字头建议列表选项时,我再次单击在打字头控件上设置的焦点之外。你可以看到同样的问题
https://valor-software.com/ngx-bootstrap/#/typeahead#reactive-forms
在这里,我发现反应形式存在同样的问题。
如果有人对此有任何选择,请告诉我。
谢谢,阿莫尔·拉詹斯。
解决方案
我在 IE 中遇到了相同的行为并创建了一个快速的解决方法。
import { Directive, Input } from '@angular/core';
import { TypeaheadDirective } from 'ngx-bootstrap';
const isIE = navigator.userAgent.indexOf('MSIE')!==-1 || navigator.appVersion.indexOf('Trident/') > -1;
@Directive({selector: '[typeaheadIeFix]', exportAs: 'bs-typeahead'})
export class TypeaheadIeFixDirective extends TypeaheadDirective {
private ie_init:boolean = false;
@Input('typeaheadIeFix') typeahead: any;
/**
* when ngModel or formControl is init'ed, it seems to update input value triggering an 'input' event in IE.
* that 'input' event then causes typeahead directive to focus on the bound input and even open its suggestion list if possible.
*/
onInput (e) {
if (isIE && !this.ie_init) {
this.ie_init = true;
return;
}
super.onInput(e);
}
}
推荐阅读
- java - Lucee,在 Windows 上,在第一次请求应用程序时附加 index.cfm
- javascript - Javascript 框架只是 javascript 的“标记”?
- java - 使用 JNI 从 C++ 调用具有非原始输出的 Java 方法
- logging - 堆树高度与 BST 高度
- javascript - 用 JavaScript 显示隐藏列表
- caching - 页面缓存和磁盘缓存有区别吗?
- java - 编写具有 3 个子类和测试器的约会超类。一切都可以编译,但用户输入后程序没有响应
- jenkins - 从 Jenkins 脚本化管道中搜索 LDAP
- lets-encrypt - certbot 无法验证域和连接被拒绝
- ajax - Google Analytics 自动跟踪 Ajax 在 jsf 应用程序中不起作用