Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 角度4-新MouseeEvent导致IE11错误_Javascript_Angular_Mouseevent_Internet Explorer 11_Angular Cli - Fatal编程技术网

Javascript 角度4-新MouseeEvent导致IE11错误

Javascript 角度4-新MouseeEvent导致IE11错误,javascript,angular,mouseevent,internet-explorer-11,angular-cli,Javascript,Angular,Mouseevent,Internet Explorer 11,Angular Cli,我对IE11上angular 4中的MouseeEvent有问题。我使用的是angular 4,angular cli 当我激活这行代码时: let newEvent = new MouseEvent('mouseleave', {bubbles: true}); IE正在控制台中抛出这样的异常: 我取消了polyfils.ts和重建项目中的所有注释,我尝试了IE和ES6垫片 我在谷歌上找不到任何类似的东西,我认为这是一个愚蠢的问题-云有人请告诉我解决方案?你可以通过以下方式欺骗IE: 从“@

我对IE11上angular 4中的MouseeEvent有问题。我使用的是angular 4,angular cli

当我激活这行代码时:

let newEvent = new MouseEvent('mouseleave', {bubbles: true});
IE正在控制台中抛出这样的异常:

我取消了polyfils.ts和重建项目中的所有注释,我尝试了IE和ES6垫片


我在谷歌上找不到任何类似的东西,我认为这是一个愚蠢的问题-云有人请告诉我解决方案?

你可以通过以下方式欺骗IE:

从“@angular/core”导入{Component,OnInit,ElementRef,ViewChild}

@ViewChild('fileInput')公共fileInput:ElementRef


html
文件中尝试:

<div #sample>You need to click me</div>
使用点击事件,如
js
as中所示:

this.sampleEle.nativeElement.click();

可能是这个吗?不,我在整页上没有任何id。:)嗨,TZ,我提供的答案对我有用。如果我帮助过你,请将其标记为一个答案,以便对正在寻找解决方案的其他人有所帮助:)嘿,这是一个如此古老的东西,我现在无法复制它,但我认为你的答案很好,所以我会接受它们。
<div #sample>You need to click me</div>
@ViewChild('sample') sampleEle: ElementRef;
this.sampleEle.nativeElement.click();