highcharts - 将 highcharts 版本从 4.1 升级到 7.12 出现错误 Uncaught ReferenceError: Highcharts is not defined
问题描述
我正在尝试升级 highcharts 版本,在控制台中不断出现错误 Uncaught ReferenceError: Highcharts is not defined
我的项目使用以下库 Jquery、dojo、骨干网、下划线。
这是我的 index.html 和我包含的库的顺序,我使用以下链接从下载的 highcharts 7.1.2下载 highcharts“ https://www.highcharts.com/blog/download/ ”
<!doctype html>
<html lang="en">
<head>
<script>
var dojoConfig = {
parseOnLoad: true,
locale: 'en',
async: true,
packages: [
{ name: "app", location: location.pathname.replace(/[^\/]+$/, "") + "js/app" },
{ name: "bootstrapmap", location: location.pathname.replace(/[^\/]+$/, "") + "libs/bower/bootstrap-map-js/src/js", main: "bootstrapmap" },
{ name: "backbone", location: location.pathname.replace(/[^\/]+$/, "") + "libs/bower/backbone", main: "backbone" },
{ name: "underscore", location: location.pathname.replace(/[^\/]+$/, "") + "libs/bower/underscore", main: "underscore" }
]
};
</script>
<script src="libs/jsapi/dojo/dojo.js" data-dojo-config="async: true"></script>
</head>
<body class="claro">
<div class="loading">
<img src="img/spinner.gif" class="loading-spinner" />
<img src="img/loading.png" class="loading-img img-responsive" />
</div>
<script src="libs/bower/jquery/dist/jquery.js"></script>
<script src="libs/bower/highcharts/highcharts.js"></script>
<script src="libs/highcharts-regression.js"></script>
<script src="libs/bower/highcharts/modules/exporting.js"></script>
<script src="libs/bower/highcharts/modules/export-data.js"></script>
<script src="libs/bootstrap.custom.js"></script>
<script src="js/main.js"></script>
</body>
</html>
我正在尝试将 highcharts 版本从 4.1 升级到 7.1.2 并下载了捆绑的全新 highcharts 版本,在项目中添加了该捆绑包,并在 jquery、highchart js 和 highcharts-regression、导出和可访问性等模块之后在正文中添加了以下脚本标签对于我的项目,我在控制台中不断收到错误 Uncaught ReferenceError: Highcharts is not defined,如果我包含我的旧 4.1 版本,它工作正常,如果我包含新版本 Uncaught ReferenceError: Highcharts is not defined,我会一直收到错误,而我检查了导致该问题的窗口上不可用的 Highcharts,我不确定即使我包含了必需的库,我仍然会收到该错误。
最近的发现: 如果我将 4.1 版升级到 5 的任何版本,它都可以正常工作,升级到 6 或 7 版无法正常工作,得到Uncaught ReferenceError: Highcharts is not defined
解决方案
我找到了解决自己问题的方法,Dojo 是问题的原因。在dojo脚本标签导致发布后添加highchart库,
解决方案: 在dojo脚本标签之前添加highchart(7.1.2)脚本标签,效果很好
工作代码:
<script src="libs/highcharts-regression.js"></script>
<script src="libs/bower/highcharts/modules/exporting.js"></script>
<script src="libs/bower/highcharts/modules/export-data.js"></script>
<script src="libs/bower/highcharts/modules/accessibility.js"></script>
<script src="libs/jsapi/dojo/dojo.js" data-dojo-config="async: true"></script>
推荐阅读
- python - float() 参数必须是字符串或数字而不是 'nonetype' 如何在 db.session 中检查和避免它们
- python-3.x - Google Cloud 登录不会记录所有消息
- python - 自平衡机器人的遗传算法实现
- ruby-on-rails - rack_attack 可以安全列出动态创建的 IP 列表(例如管理员最近使用的 IP)吗?
- apache-spark - 使用保留关键字和正则表达式引发 sql 歧义
- java - 如何将多线程合并到 IDA* 搜索算法中?
- flutter - 我如何使用cubit检查连接性?
- bootstrap-5 - 如何使用弹出框创建 Bootstrap 5 下拉菜单
- arrays - 组合二维数组(矩阵)元素
- php - 如何应用正则表达式从动态字符串中获取数字