谷歌可视化 API 查询引用错误:未定义"google"



当我把这段代码粘贴到我的脚本中时会发生什么:

https://code.google.com/apis/ajax/playground/?type=visualization#using_the_query_language

并运行它,它会给我这个错误:

ReferenceError:未定义"google"。

需要首先加载"Google Visualization API":按照快速启动。

您可以将下面的片段复制到计算机上的文件中,然后在浏览器中打开它,以显示上面显示的饼图:

来自链接的代码段:

<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
  // Load the Visualization API and the piechart package.
  google.load('visualization', '1.0', {'packages':['corechart']});
  // Set a callback to run when the Google Visualization API is loaded.
  google.setOnLoadCallback(drawChart);
  // Callback that creates and populates a data table,
  // instantiates the pie chart, passes in the data and
  // draws it.
  function drawChart() {
    // !!! Use Google Visualization API here !!!
  }
</script>

请注意,在调用drawChart后,Google可视化API仅可用。

最新更新