You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何强制Chrome使用指定版本Google Charts?解决加载报错问题

Google Charts版本冲突与Chrome报错解决方案

解决Chrome构造函数报错

报错Uncaught TypeError: google.visualization.Columnchart is not a constructor是大小写敏感问题:

  • Chrome对JavaScript标识符大小写严格校验,将代码中的google.visualization.Columnchart改为google.visualization.ColumnChart(注意最后一个C大写)即可解决该报错。

解决版本冲突警告(Firefox提示)

警告Attempting to load version '1' of Google Charts, but the previously loaded '1.0' will be used instead是版本指定不一致或重复加载导致,按以下步骤处理:

  • 统一版本指定:所有加载代码使用同一个版本标识,避免混合'1'和'1.0'。示例代码:
    <script src="https://www.gstatic.com/charts/loader.js"></script>
    <script>
      // 要么用稳定的指定版本
      google.charts.load('1.0', {'packages':['corechart']});
      // 要么用最新稳定版
      // google.charts.load('current', {'packages':['corechart']});
      google.charts.setOnLoadCallback(drawChart);
    
      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['类别', '数值'],
          ['A', 100],
          ['B', 150]
        ]);
        var options = {title: '示例图表'};
        // 使用修正后的构造函数
        var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
        chart.draw(data, options);
      }
    </script>
    
  • 移除重复加载:检查页面中是否多次引入loader.js,确保仅保留一处加载脚本,避免版本冲突。

Chrome强制加载指定版本

  • 按Ctrl+Shift+R(Windows/Linux)或Cmd+Shift+R(Mac)强制刷新页面,清除Chrome缓存中旧的Google Charts资源。
  • 若仍有问题,可在Chrome开发者工具的「网络」面板中勾选「禁用缓存」,重新加载页面调试。

内容的提问来源于stack exchange,提问作者Satish Sawant

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 09:22:45