Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使我的angular 4代码与firefox兼容?_Angular_Typescript - Fatal编程技术网

如何使我的angular 4代码与firefox兼容?

如何使我的angular 4代码与firefox兼容?,angular,typescript,Angular,Typescript,我已经在chrome浏览器中测试了angular 4代码,但现在当我在firefox中打开它时,它给出了以下错误 ERROR TypeError: hostEl.createShadowRoot is not a function Stack trace: ShadowDomRenderer@http://localhost:4200/vendor.bundle.js:166030:28 ../../../platform-browser/@angular/platform-browser.es

我已经在chrome浏览器中测试了angular 4代码,但现在当我在firefox中打开它时,它给出了以下错误

ERROR TypeError: hostEl.createShadowRoot is not a function
Stack trace:
ShadowDomRenderer@http://localhost:4200/vendor.bundle.js:166030:28
../../../platform-browser/@angular/platform-browser.es5.js/DomRendererFactory2.prototype.createRenderer@http://localhost:4200/vendor.bundle.js:165743:24
../../../platform-browser/@angular/platform-browser/animations.es5.js/AnimationRendererFactory.prototype.createRenderer@http://localhost:4200/vendor.bundle.js:167745:41
../../../core/@angular/core.es5.js/</DebugRendererFactory2.prototype.createRenderer@http://localhost:4200/vendor.bundle.js:127912:35
createComponentView@http://localhost:4200/vendor.bundle.js:126511:24
callWithDebugContext@http://localhost:4200/vendor.bundle.js:127880:39
debugCreateComponentView@http://localhost:4200/vendor.bundle.js:127237:12
createViewNodes@http://localhost:4200/vendor.bundle.js:126569:37
createRootView@http://localhost:4200/vendor.bundle.js:126494:5
callWithDebugContext@http://localhost:4200/vendor.bundle.js:127880:39
debugCreateRootView@http://localhost:4200/vendor.bundle.js:127197:12
错误类型错误:hostEl.createShadowRoot不是函数
堆栈跟踪:
ShadowDomRenderer@http://localhost:4200/vendor.bundle.js:166030:28
../../../platform browser/@angular/platform-browser.es5.js/domrenderFactory2.prototype。createRenderer@http://localhost:4200/vendor.bundle.js:165743:24
../../../platform browser/@angular/platform browser/animations.es5.js/animationrenderfactory.prototype。createRenderer@http://localhost:4200/vendor.bundle.js:167745:41
../../../core/@angular/core.es5.js/如果您使用(ViewEncapsulation.Native)封装本机shadow DOM,您必须知道它仅在chrome中可用,请使用emulated,或者您可以将其与其他浏览器集成以实现web组件兼容性,我认为您没有其他选择
可以通过以下方式使用多边形填充:

  npm install @webcomponents/webcomponentsjs
您可以使用webcomponents sd ce自定义元素和阴影DOM: 将其添加到polyfills.ts

import '@webcomponents/webcomponentsjs/webcomponents-sd-ce.js';

有效的解决方案来自链接

https://github.com/angular/angular/issues/6531
i、 e.从所有typescript文件中删除ViewEncapsulation.None或ViewEncapsulation.Native

并将任何css文件添加到index.html文件中


其他使用polyfills的解决方案没有解决该问题,并开始从jquery-2.1.3.min.js文件中获得相同的错误。

谢谢,您知道如何使用它在typescript或angular 4中使用它吗npm@Fateh,获取错误as=>error in./src/polyfills.ts模块未找到:错误:无法解析“@webcomponents/webcomponentsjs/webcomponents sd-ce.js”是否存在类似webcomponents sd-ce.js的文件?在较新版本上的import语句如下所示
import'@webcomponents/webcomponentsjs/bundles/webcomponents sd-ce'顺便说一句,解决方案无效,请检查此项