簡體   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