Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/405.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 类型错误google.visualization.DataTable不是构造函数_Javascript_Html_Google Apis Explorer_Jsapi - Fatal编程技术网

Javascript 类型错误google.visualization.DataTable不是构造函数

Javascript 类型错误google.visualization.DataTable不是构造函数,javascript,html,google-apis-explorer,jsapi,Javascript,Html,Google Apis Explorer,Jsapi,我试图使用GoogleChart创建一个表,但是它返回了table方法的构造错误。我看到了一些引用,但我认为错误是jsapi库中给出的,所以google没有定义 > Uncaught TypeError: Cannot redefine property: Map at defineProperty (<anonymous>) at gvjs_bc (jsapi_compiled_format_module.js:13) at jsapi_compile

我试图使用GoogleChart创建一个表,但是它返回了table方法的构造错误。我看到了一些引用,但我认为错误是jsapi库中给出的,所以google没有定义

> Uncaught TypeError: Cannot redefine property: Map
    at defineProperty (<anonymous>)
    at gvjs_bc (jsapi_compiled_format_module.js:13)
    at jsapi_compiled_format_module.js:28
> Uncaught TypeError: Cannot read property 'Xc' of undefined
    at jsapi_compiled_default_module.js:33
> Uncaught TypeError: Cannot use 'in' operator to search for 'google' in undefined
    at gvjs_k (jsapi_compiled_format_module.js:33)
    at jsapi_compiled_bar_module.js:17
> Uncaught TypeError: Cannot use 'in' operator to search for 'google' in undefined
    at gvjs_k (jsapi_compiled_format_module.js:33)
    at jsapi_compiled_table_module.js:5
 > Uncaught (in promise) TypeError: google.visualization.DataTable is not a constructor
    at drawChartUsersActive (UsersActive:280)
    at drawCharts (UsersActive:276)
    at loader.js:248
>未捕获类型错误:无法重新定义属性:映射
在定义属性()
在gvjs_bc(jsapi_编译的_格式_module.js:13)
在jsapi_编译的_格式_module.js:28
>未捕获的TypeError:无法读取未定义的属性“Xc”
在jsapi_编译的_default_module.js:33
>未捕获的TypeError:无法使用“in”运算符在未定义的中搜索“google”
在gvjs_k(jsapi_编译的格式_module.js:33)
在jsapi_编译的_bar_module.js:17
>未捕获的TypeError:无法使用“in”运算符在未定义的中搜索“google”
在gvjs_k(jsapi_编译的格式_module.js:33)
在jsapi_编译的_table_module.js:5
>未捕获(承诺中)TypeError:google.visualization.DataTable不是构造函数
在drawChartUsersActive(UsersActive:280)
在图纸上(用户活动:276)
at loader.js:248
这是我的html代码,正如您所看到的,它非常简单,我只是试图绘制表格,但总是返回这些错误

<html>
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.1/jquery.min.js"></script>
    <script src="https://www.gstatic.com/charts/loader.js"></script>
    <meta name="layout" content="bootstrap">
  </head>
  <body>
    <div class="cabecalho"></div>
    <div id="table_div"></div>

    <script type="text/javascript">
      google.charts.load('current', {
        packages: ['bar', 'corechart', 'table'],
        callback: drawCharts
      });

      function drawCharts() {
        drawChartUsersActive();
      }

      function drawChartUsersActive() {
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Name');
        data.addColumn('number', 'Salary');
        data.addColumn('boolean', 'Full Time Employee');
        data.addRows([
          ['Mike',  {v: 10000, f: '$10,000'}, true],
          ['Jim',   {v:8000,   f: '$8,000'},  false],
          ['Alice', {v: 12500, f: '$12,500'}, true],
          ['Bob',   {v: 7000,  f: '$7,000'},  true]
        ]);

        var table = new google.visualization.Table(document.getElementById('table_div'));

        table.draw(data, {showRowNumber: true, width: '100%', height: '100%'});
      }
    </script>
  </body>

</html>

google.charts.load('current'{
软件包:['bar','corechart','table'],
回调:图纸
});
函数绘图图(){
DrawChartUsersActivity();
}
函数drawChartUsersActivity(){
var data=new google.visualization.DataTable();
data.addColumn('string','Name');
data.addColumn('number','Salary');
data.addColumn('boolean','全职雇员');
data.addRows([
['Mike',{v:10000,f:'10000'},对],
['Jim',{v:8000,f:'8000'},假],
['Alice',{v:12500,f:'12500'},对],
['Bob',{v:7000,f:'7000'},对]
]);
var table=新的google.visualization.table(document.getElementById('table_div');
table.draw(数据,{showRowNumber:true,宽度:'100%,高度:'100%});
}

您是否尝试替换:

google.charts.load('current', {
    packages: ['bar', 'corechart', 'table'],
    callback: drawCharts
  });

  function drawCharts() {
    drawChartUsersActive();
  }
作者:

这只是写在文档中的内容,所以它可能有效;)

google.charts.load('current', {'packages':['table']});
google.charts.setOnLoadCallback(drawChartUsersActive());