繁体   English   中英

zone.js:25未捕获的错误:区域已加载

[英]zone.js:25 Uncaught Error: Zone already loaded

单击按钮即可加载我的角度应用程序。 单击按钮时,由于第一次加载angular2时会加载zone.js内容,因此出现Zone already loaded错误。

我将如何检查区域是否已加载,然后如何阻止尝试加载该区域(如果可用)?

当我通过delete window['zone']删除(在下面回答)区域并尝试再次重新加载它时,显示的zone.js:984 Uncaught ReferenceError: Zone is not defined

您可以尝试这样的事情...

 $(function (){ function removejscssfile(filename, filetype){ var targetelement=(filetype=="js")? "script" : (filetype=="css")? "link" : "none" //determine element type to create nodelist from var targetattr=(filetype=="js")? "src" : (filetype=="css")? "href" : "none" //determine corresponding attribute to test for var allsuspects=document.getElementsByTagName(targetelement) for (var i=allsuspects.length; i>=0; i--){ //search backwards within nodelist for matching elements to remove if (allsuspects[i] && allsuspects[i].getAttribute(targetattr)!=null && allsuspects[i].getAttribute(targetattr).indexOf(filename)!=-1) allsuspects[i].parentNode.removeChild(allsuspects[i]) //remove element by calling parentNode.removeChild() } } var jsCustomerTag = $("head").children("#jsShimTag"); if (jsCustomerTag.length == 0) { jsCustomerTag = document.createElement('script'); jsCustomerTag.setAttribute("type", "text/javascript"); jsCustomerTag.setAttribute("src", " <your js file> "); jsCustomerTag.id = "jsShimTag"; document.getElementsByTagName("head")[0].appendChild(jsCustomerTag); } jsCustomerTag = null; }); 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM