获取错误'无法读取属性'文档'未定义的'在导入exporting.js时(导出高图表)

Getting error 'Cannot read property 'document' of undefined' while importing exporting.js (to export highchart charts)

本文关键字:js exporting 高图表 导入 未定义 取错误 读取 属性 获取 文档      更新时间:2023-09-26

我正在尝试将高图表导出到PDF文件中。为此,我已经读到我应该使用exporting.js(以及其他库)。但是当我导入这个库(exporting.js)时,我会收到这样的错误:"无法读取未定义的属性"document"。"。

我从javascript:导入

var newscript = document.createElement('script');
newscript.type = 'text/javascript';
newscript.async = true;
newscript.src = '/resources/tda-ga/js/charts/lib/exporting.js';
(document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(newscript);

我将感谢任何帮助!

请验证您是否拥有相同版本的exporting.js和highcharts.js模块。看起来你指的是最新的exporting.js,而不是最新的highcharts.js.