Uncaught TypeError:useValue,useFactory,数据是不可迭代的! Angular 4 cli项目错误
我是Angular 4的新手,我刚刚创build了一个Angular Cli的项目,我得到了错误
Uncaught TypeError: useValue,useFactory,data is not iterable!
我无法解决它。 我安装并重新安装了cli,我只是想知道如何解决它。 我所做的只是
ng new myprj mkdir myprj ng serve
我通过将es6-shim添加到我的index.html文件的脚本标记中解决了问题:
<script> src =“https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.22.1/ es6-shim.min.js”> </ s cript>
在我的Travis部署期间运行ng test
时,我遇到了同样的问题,即使它在本地执行没有错误。
Chromium 37.0.2062 (Ubuntu 0.0.0) ERROR Uncaught TypeError: useValue,useFactory,data is not iterable! at http://localhost:9876/_karma_webpack_/polyfills.bundle.js:830
如果您的问题与我的相同,则需要转至项目中的polyfills.ts文件以启用向后兼容性。
注释中提到的注释和打包安装有多行。 其中一些是为了在任何版本的IE上运行而需要的。
帮助过我。
这种错误通常发生在浏览器缺less新function的情况下。 可以通过添加polyfill来轻松修复
import 'core-js/es6/symbol'; import 'core-js/es6/object'; import 'core-js/es6/function'; import 'core-js/es6/parse-int'; import 'core-js/es6/parse-float'; import 'core-js/es6/number'; import 'core-js/es6/math'; import 'core-js/es6/string'; import 'core-js/es6/date'; import 'core-js/es6/array'; import 'core-js/es6/regexp'; import 'core-js/es6/map'; import 'core-js/es6/weak-map'; import 'core-js/es6/set';
到你的供应商文件或文件开始你的testing,如果你在karma.config.js切换
browsers: ['Chrome'] to browsers: ['PhantomJS']
或者在运行testing后得到这个错误