作者:longxi | 来源:互联网 | 2023-02-11 19:36
我的Angular 2项目是使用angular-cli版本1.0.0-beta.30创建的.我正在使用ngx-charts版本4.1.2库.条形图组件工作正常,但是当我添加折线图时,运行应用程序时会引发TypeError异常.在Chrome版本38中运行时,错误是[line-chart.component.ts] [1]源文件的第240行中的"包含"功能.在Firefox中正确显示折线图
if (!values.includes(d.name)) {
values.push(d.name);
}
如何使数组包含我的应用程序已知的函数?
在我的tsconfig.json文件中
"lib": ["es6", "dom"],
我的package.json文件包含以下内容
{
"name": "dashboards",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/common": "^2.4.5",
"@angular/compiler": "^2.4.5",
"@angular/core": "^2.4.5",
"@angular/forms": "^2.4.5",
"@angular/http": "^2.4.5",
"@angular/platform-browser": "^2.4.5",
"@angular/platform-browser-dynamic": "^2.4.5",
"@angular/router": "^3.4.1",
"@swimlane/ngx-charts": "^4.1.2",
"core-js": "^2.4.1",
"d3": "^4.4.0",
"rxjs": "^5.0.3",
"ts-helpers": "^1.1.2",
"zone.js": "^0.7.6"
},
"devDependencies": {
"@angular/cli": "1.0.0-beta.30",
"@angular/compiler-cli": "^2.4.5",
"@types/d3": "^4.4.0",
"@types/jasmine": "2.5.38",
"@types/node": "^6.0.42",
"codelyzer": "~2.0.0-beta.1",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "2.7.0",
"karma": "1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.1.0",
"karma-remap-istanbul": "^0.4.0",
"protractor": "~4.0.14",
"ts-node": "1.7.2",
"tslint": "^4.3.0",
"typescript": "~2.0.10"
}
}
我的polyfills.ts文件包含
import 'core-js/es6/array';
我查看了ngx-charts演示和其他示例,但我无法弄清楚为什么我收到错误.
谢谢
1> autowired..:
我发现了这个问题.包含polyfills.ts文件
import 'core-js/es6/array';
我需要补充一下
import 'core-js/es7/array';
到文件.
我认为这是因为我公司的PC上安装了Chrome版本.它是版本38.此Array.include的developer.mozilla.org页面包含支持Chrome的版本47.