我在 IE11 上的 Angular 4 中遇到 mouseEvent 问题。我正在使用 Angular 4,Angular-CLI。
当我激活这行代码时:
let newEvent = new MouseEvent('mouseleave', {bubbles: true});
IE 在控制台中抛出此类异常:
TypeError: Object does not support this operation. at MenuItemComponent.prototype.onClick (./main.bundle.js:821:13) at Anonymous function (Function code:37:9) at handleEvent (./vendor.bundle.js:12039:87) at callWithDebugContext (./vendor.bundle.js:13247:9) at debugHandleEvent (./vendor.bundle.js:12835:5) at dispatchEvent (./vendor.bundle.js:9014:5) at Anonymous function (./vendor.bundle.js:9604:31) at Anonymous function (./vendor.bundle.js:19253:9) at ZoneDelegate.prototype.invokeTask (./polyfills.bundle.js:10732:13) at onInvokeTask (./vendor.bundle.js:4357:21) at ZoneDelegate.prototype.invokeTask (./polyfills.bundle.js:10732:13) at Zone.prototype.runTask (./polyfills.bundle.js:10501:21) at invoke (./polyfills.bundle.js:10796:21)
我取消了我的 polyfils.ts 中所有内容的注释并重建了项目,我尝试过 IE 和 ES6 shim...
我在 Google 中找不到类似的内容,我认为这是一些愚蠢的问题 - 云有人请给我指出解决方案吗?
最佳答案
在 html
文件中尝试:
<div #sample>You need to click me</div>
在 component.js 文件中:
@ViewChild('sample') sampleEle: ElementRef;
并使用 js
中的点击事件:
this.sampleEle.nativeElement.click();
关于javascript - Angular 4 - 新的 MouseEvent 导致 IE11 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43655331/