Highchart未捕获的错误-未捕获的类型错误:$(…).Highcharts不是一个函数



我目前正在使用Highcharts,它一直在控制台给我这个错误:Uncaught TypeError: $(...).highcharts is not a function

我已经搜索了一个解决方案,所有的人都说,你需要把jquery脚本以上的HighCharts脚本如下:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>

但是它仍然给我那个错误。是因为jquery的版本吗?

下面是我的代码: HTML:

<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

JS:

$(function () {
            $('#container').highcharts({
                chart: {
                    type: 'line'
                },
                title: {
                    text: 'Monthly Average Temperature'
                },
                subtitle: {
                    text: 'Source: WorldClimate.com'
                },
                xAxis: {
                    categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
                },
                yAxis: {
                    title: {
                        text: 'Temperature (°C)'
                    }
                },
                plotOptions: {
                    line: {
                        dataLabels: {
                            enabled: true
                        },
                        enableMouseTracking: false
                    }
                },
                series: [{
                    name: 'Tokyo',
                    data: [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
        }, {
                    name: 'London',
                    data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
        }]
            });
        });

有什么我没看到的吗?

谢谢你的帮助!

我找到解决方案了!

这很简单。我使用的是基础6基本模板,显然在关闭</body>标签之前,有这个脚本标签<script src="bower_components/jquery/dist/jquery.js"></script>,如果我删除它,就没有错误。只是我犯了一个严重的错误。

祝你今天愉快!

最新更新