VS2015 + Cordova + SystemJS + 安全限制错误:0x800c001c [英] VS2015 + Cordova + SystemJS + Security Restriction Error: 0x800c001c

查看:35
本文介绍了VS2015 + Cordova + SystemJS + 安全限制错误:0x800c001c的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我调试 Windows Phone 8.1 和 Windows Phone 10 的 Cordova 项目时,我收到一个 未处理的异常 0x800c001c.问题是 document.write 中使用的 document.write代码>System.js.

我了解 winstore-jscompat.js 使用了

当我查看 dom 时,我可以看到 winstore-jscompat.js 是由 platformOverrides.js 动态添加的,并且位于调用 system.js 之前.

项目代码可以在这里下载https://github.com/dbiele/TypeScript-Cordova-SystemJS

有什么想法吗?不确定这是否是我的构建机器的问题.注意:问题出现在使用模拟器和物理设备时.

解决方案

@guybedford 能够回答这个问题.这是他的回应:

https://github.com/systemjs/systemjs/issues/825

<块引用>

这是 SystemJS 在需要加载 Promise 和 URL polyfills 文件时所做的自动加载 - https://github.com/systemjs/systemjs/blob/master/dist/system-polyfills.js.这在包括 Edge 在内的 IE 环境中总是需要的.如果您只是在加载 SystemJS 之前手动包含带有脚本标记的文件,则不会再发出该动态请求.

我将 platformOverrides.js 更新为:

(函数(){//附加 safeHTML polyfillvar scriptElem = document.createElement('script');scriptElem.setAttribute('src', 'scripts/winstore-jscompat.js');var scriptElem2 = document.createElement('script');scriptElem.setAttribute('src', 'scripts/system-polyfills.js');如果(文档.正文){document.body.appendChild(scriptElem);document.body.appendChild(scriptElem2);} 别的 {document.head.appendChild(scriptElem);document.head.appendChild(scriptElem2);}}());

I'm getting an Unhandled exception 0x800c001c when I debug my Cordova project for Windows Phone 8.1 and Windows Phone 10. The problem is the document.write used in System.js.

I understand winstore-jscompat.js link is used to resolve this problem, and the <script src="... element is in the index HTML. However, it doesn't seem to solve the dynamic content problem with Windows Phone.

When I look at the dom I can see winstore-jscompat.js is dynamically added by platformOverrides.js and is located before system.js is called.

The project code can be download here https://github.com/dbiele/TypeScript-Cordova-SystemJS

Any thoughts? Not sure if this is a problem with my build machine. Note: The problem happens when using emulators and physical devices.

解决方案

@guybedford was able to answer the question. Here's his response:

https://github.com/systemjs/systemjs/issues/825

this is the automatic loading SystemJS does when it needs to load the Promise and URL polyfills file at - https://github.com/systemjs/systemjs/blob/master/dist/system-polyfills.js. This is always needed in IE environments including Edge. If you just include that file with a script tag manually before loading SystemJS it won't make that dynamic request anymore.

I updated my platformOverrides.js to:

(function () {
// Append the safeHTML polyfill
var scriptElem = document.createElement('script');
scriptElem.setAttribute('src', 'scripts/winstore-jscompat.js');
var scriptElem2 = document.createElement('script');
scriptElem.setAttribute('src', 'scripts/system-polyfills.js');
if (document.body) {
    document.body.appendChild(scriptElem);
    document.body.appendChild(scriptElem2);
} else {
    document.head.appendChild(scriptElem);
    document.head.appendChild(scriptElem2);
}
}());

这篇关于VS2015 + Cordova + SystemJS + 安全限制错误:0x800c001c的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆