2016-09-16 15 views
0

我目前Highcharts工作,它不斷給我在控制檯此錯誤:Uncaught TypeError: $(...).highcharts is not a function

我尋覓繞瞭解決方案和所有說你需要將上述這樣的HighCharts腳本的jQuery腳本:

<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] 
     }] 
      }); 
     }); 

是否有我沒有看到的東西嗎?

感謝您的幫助!

+0

請驗證是否所有文件都正確加載 – brk

回答

0

我找到了解決方案!

這很簡單。我正在使用Foundation 6基本模板,顯然在關閉</body>標記之前有這個腳本標記<script src="bower_components/jquery/dist/jquery.js"></script>,如果我刪除了它,則沒有錯誤。從我身邊犯錯誤。

祝您有美好的一天!

+1

下次,https://en.wikipedia.org/wiki/Rubber_duck_debugging – Weedoze

相關問題