直接到我正在下载图表的 PDF 时,我在浏览器控制台上遇到上述异常,显示“未捕获的类型错误:无法读取未定义的属性“0””。
不知道为什么会出现此错误。我还有其他报告,下载效果很好。但有时我会遇到这个问题。我正在运行的代码如下。
我正是在这一行遇到问题 window[theSelectedChart].exportChart({
谁能帮帮我。提前致谢。
if(theSelectedChart == 'somechart') {
if(Shortform.chartType == 'bubble'){
var maxDays = Math.max.apply(Math, Shortform.activeDays);
var minDays = Math.min.apply(Math, Shortform.activeDays);
window[theSelectedChart].xAxis[0].setExtremes(minDays - 1, maxDays + 1);
} else {
window[theSelectedChart].xAxis[0].setExtremes(0, categoriesLength);
}
} else {
window[theSelectedChart].xAxis[0].setExtremes(0, categoriesLength - 1);
}
window[theSelectedChart].exportChart({
type: "application/pdf",
url: 'export-chart/',
filename: localizedShortformExportFilenames[key],
sourceWidth:(categoriesLength * 12 > 600) ? categoriesLength * 12 : 800,
},{
scrollbar : {
enabled : false,
},
chart : {
marginTop : getMarginTop(selectedThumbnail),
spacingRight : 30,
},
title: {
y:5,
},
subtitle : {
y : 15
},
});
最佳答案
您不应该使用“window”作为变量名。它保留用于引用您在其中运行 JavaScript 和其他代码的浏览器窗口。对于您的窗口数组,请使用不同的名称,例如“windw”。
关于javascript - 未捕获的类型错误 : Cannot read property '0' of undefined javascript error and with highcharts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26385051/