我在 Closure 的开发模式下遇到了问题,因为我的 Chrome 打包应用程序(即 v2 list 文件)的安全策略限制了 Closure 引导过程中调用的内容(例如,当我使用未编译的应用程序加载应用程序时)开发代码时,我得到“document.write() 在打包应用程序的沙箱中不可用”)。
最佳答案
以下代码是我最终使用的代码,它非常适合在 Chrome 的打包应用框架内以开发模式运行 Closure。
在closure/goog/base.js中,覆盖goog.global.CLOSURE_IMPORT_SCRIPT,如下所示:
goog.global.CLOSURE_IMPORT_SCRIPT = function(src) {
var script = document.createElement('script');
script.src = src;
script.type = 'text/javascript';
goog.global.document.getElementsByTagName("head")[0].appendChild(script);
return true;
};
关于javascript - 关闭开发模式和 Chrome 打包应用程序 -- "document.write() is not available in the sandbox of packaged apps",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15279728/