-2

您好,以下是我的完整 HTML 和 Javascript 代码,但在浏览器中运行时显示错误Uncaught ReferenceError: draw is not defined test.html:13

<html>
    <head>
        <title>Testing D3</title>
        <script type="text/javascript" src="d3-v5.js"/>
        <script type="text/javascript">
            function draw(data){
                console.log(data);
            }
        </script>
    </head>
    <body>
        <script type="text/javascript">
            draw(12);
        </script>
    </body>
</html>
4

1 回答 1

0

您显然不能使用自闭合标签,将 d3 导入更改为:

  <script type="text/javascript" src="d3-v5.js"></script>

<html>
    <head>
        <title>Testing D3</title>
        <script type="text/javascript" src="d3-v5.js"></script>
        <script type="text/javascript">
            function draw(data){
                console.log(data);
            }
        </script>
    </head>
    <body>
        <script type="text/javascript">
            draw(12);
        </script>
    </body>
</html>

于 2018-06-10T04:39:06.837 回答