未捕获的语法错误:输入JavaScript意外结束

Uncaught SyntaxError: Unexpected end of input JavaScript

本文关键字:输入 JavaScript 意外 结束 错误 语法      更新时间:2023-10-06

我是js的新手,一直收到错误"Uncaught SyntaxError:Unexpected end of input",在我的一生中都不知道这个错误是什么。有人看到我可能忽略了什么吗?感谢

 <html>
    <head>
        <script type="text/javascript" src="https://www.google.com/jsapi"></script>
        <script type="text/javascript">
        google.load("visualization", "1", {packages:["motionchart"]});
        google.setOnLoadCallback(drawChart);
        function drawChart() {
            var data = new google.visualization.DataTable();
            data.addColumn('string', 'Type of App');
            data.addColumn('date', 'Date');
            data.addColumn('number', 'Sales');
            data.addRows([
              ['Apps',  new Date (2009,0,1), 2380],
              ['Games',  new Date (2009,0,1), 571],
              ['Games', new Date (2009,0,6), 978],
              ['Apps',  new Date (2009,0,12), 14069],
              ['Games',  new Date (2009,0,12), 2307],
              ['Apps', new Date (2010,0,1), 11465],
              ['Games', new Date (2010,0,1), 1520],
              ['Apps',  new Date (2010,0,6), 13490],
              ['Games',  new Date (2010,0,6), 2126],
              ['Apps', new Date (2010,0,12), 20285],
              ['Games', new Date (2010,0,12), 4025],
              ['Games',  new Date (2011,0,1), 2820],
              ['Apps', new Date (2011,0,6), 12757],
              ['Apps',  new Date (2011,0,12), 16785],
              ['Apps', new Date (2012,0,1), 16097],
              ['Apps',  new Date (2012,0,6),17449],
              ['Games',  new Date (2012,0,6), 3694],
              ['Apps', new Date (2012,0,12), 21691],
              ['Games', new Date (2012,0,12), 5774],
              ['Games',  new Date (2013,0,1), 4903],
              ['Apps', new Date (2013,0,6), 23295],
              ['Games', new Date (2013,0,6), 5323],
              ['Apps',  new Date (2013,0,12), 27733],
              ['Games',  new Date (2013,0,12), 9105],
              ['Apps', new Date (2014,0,1), 30771],
              ['Games', new Date (2014,0,1), 7289],
              ['Apps',  new Date (2014,0,6), 32992],
              ['Games',  new Date (2014,0,6), 11752],
              ['Apps', new Date (2014,0,12), 30816],
              ['Apps',  new Date (2015,0,1), 29866],
              ['Games',  new Date (2015,0,1), 10183]
              ]);
    var chart = new google.visualization.MotionChart(document.getElementById('chart_div'));
    chart.draw(data, {width: 600, height:300});
    </script>
    </head>
    <body>
        <div id="chart_div" style="width: 600px; height: 300px;"></div>
    </body>
    </html>

JS Lint是您的朋友。drawChart函数(第45行)末尾缺少一个结束符"}"。

您缺少function drawChart() {的关闭"}"。