繁体   English   中英

将AngularJS 1.4.7注入IE交叉延伸器扩展

[英]Injecting AngularJS 1.4.7 into an IE crossrider extension

我正在使用Crossrider框架为浏览器开发扩展。 我正在使用这条线

appAPI.resources.includeJS('js/angular.min.js');

将angular.js注入扩展名。 这在Chrome上工作正常,但在IE 11上我收到错误

---- JS Exception from: IE test staging ----
Error: Object expected
Source: Microsoft JScript runtime error
Location: resources
Line: 131

我环顾四周,发现了一些答案,表明jQuery可能会丢失,或者代码本身可能有一个尾随逗号。 但是,我正在使用

var jq = document.createElement('script');
jq.src = "http://code.jquery.com/jquery-1.11.3.js";
document.getElementsByTagName('body')[0].appendChild(jq);

将jquery注入到文档中,这应该不是问题。 至于JS中有一个尾随逗号的可能性,我从AngularJS的缩小版本变为非透明版本,但仍然得到了同样的错误,这让我觉得错误中的行号没有意义。 如果这是关心,或忘记,无论是什么情况。 有人可以告诉我发生了什么以及如何解决它?

PS。 我的环境是在Ubuntu 14.04 LTS x64位计算机上的VMWare Workstation 12上的Windows 7 Ultimate 32位

我认为你这里有混合范围问题。 appAPI.resources.includeJS在扩展页范围内运行,您添加的jq元素在HTML页范围中运行。 如果要将AngularJS添加到HTML页面范围,请使用appAPI.resources.addInlineJS ,如下所示:

var jq = document.createElement('script');
jq.src = "https://http://code.jquery.com/jquery-1.11.3.js";
document.getElementsByTagName('body')[0].appendChild(jq);
appAPI.resources.addInlineJS('js/angular.min.js');

[ 披露:我是Crossrider员工]

暂无
暂无

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

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