我在我的项目中有一些图表似乎工作得很好。实际上,当我尝试在internet explorer中刷新页面时,我发现了这个错误:
错误错误:未捕获(在承诺中):错误:错误版本: 45.2
这指的是我的图表和插件坏了。这是我在chart.service.loader中找到的版本,但如果我尝试用以前的版本更改它,我会遇到相同的错误。
你能帮帮我吗?
这是我的情况:
Angular CLI: 6.0.3
Node: 8.9.4
OS: win32 x64
Angular: 6.0.3
@angular-devkit/schematics 0.6.3
@ngtools/webpack 6.0.3
@schematics/angular 0.6.3
@schematics/update 0.6.3
rxjs 6.2.0
typescript 2.7.2
webpack 4.8.3Ng2-google-chart有3.3版本的自动柜员机,我刚把它从3.4改了。Angular没有更新,我也只是更新了它,但没有什么变化。
谢谢
发布于 2018-05-24 20:21:08
import { Injectable, EventEmitter, LOCALE_ID, Inject } from '@angular/core';
var GoogleChartsLoaderService = /** @class */ (function () {
function GoogleChartsLoaderService(localeId) {
this.chartPackage = {
AnnotationChart: 'annotationchart',
AreaChart: 'corechart',
Bar: 'bar',
BarChart: 'corechart',
BubbleChart: 'corechart',
Calendar: 'calendar',
CandlestickChart: 'corechart',
ColumnChart: 'corechart',
ComboChart: 'corechart',
PieChart: 'corechart',
Gantt: 'gantt',
Gauge: 'gauge',
GeoChart: 'geochart',
Histogram: 'corechart',
Line: 'line',
LineChart: 'corechart',
Map: 'map',
OrgChart: 'orgchart',
Sankey: 'sankey',
Scatter: 'scatter',
ScatterChart: 'corechart',
SteppedAreaChart: 'corechart',
Table: 'table',
Timeline: 'timeline',
TreeMap: 'treemap',
WordTree: 'wordtree'
};
this.googleScriptLoadingNotifier = new EventEmitter();
this.googleScriptIsLoading = false;
this.localeId = localeId;
}
GoogleChartsLoaderService.prototype.load = function (chartType, apiKey) {
var _this = this;
return new Promise(function (resolve, reject) {
if (resolve === void 0) { resolve = Function.prototype; }
if (reject === void 0) { reject = Function.prototype; }
_this.loadGoogleChartsScript().then(function () {
var initializer = {
packages: [_this.chartPackage[chartType]],
language: _this.localeId,
callback: resolve
};
if (apiKey) {
initializer.mapsApiKey = apiKey;
}
google.charts.load('45.2', initializer);
}).catch(function (err) { return reject(); });
});
};
GoogleChartsLoaderService.prototype.loadGoogleChartsScript = function () {
var _this = this;
return new Promise(function (resolve, reject) {
if (resolve === void 0) { resolve = Function.prototype; }
if (reject === void 0) { reject = Function.prototype; }
if (typeof google !== 'undefined' && google.charts) {
resolve();
}
else if (!_this.googleScriptIsLoading) {
_this.googleScriptIsLoading = true;
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://www.gstatic.com/charts/loader.js';
script.async = true;
script.defer = true;
script.onload = function () {
_this.googleScriptIsLoading = false;
_this.googleScriptLoadingNotifier.emit(true);
resolve();
};
script.onerror = function () {
_this.googleScriptIsLoading = false;
_this.googleScriptLoadingNotifier.emit(false);
reject();
};
document.getElementsByTagName('head')[0].appendChild(script);
}
else {
_this.googleScriptLoadingNotifier.subscribe(function (loaded) {
if (loaded) {
resolve();
}
else {
reject();
}
});
}
});
};
GoogleChartsLoaderService.decorators = [
{ type: Injectable },
];
/** @nocollapse */
GoogleChartsLoaderService.ctorParameters = function () { return [
{ type: undefined, decorators: [{ type: Inject, args: [LOCALE_ID,] },] },
]; };
return GoogleChartsLoaderService;
}());
export { GoogleChartsLoaderService };https://stackoverflow.com/questions/50486530
复制相似问题