Привет, ниже приведен мой полный код 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.info(data);
}
</script>
</head>
<body>
<script type = "text/javascript">
draw(12);
</script>
</body>
</html>
Возможный дубликат Почему не работают самозакрывающиеся теги скрипта?



![Безумие обратных вызовов в javascript [JS]](https://i.imgur.com/WsjO6zJb.png)


Очевидно, вы не можете использовать самозакрывающийся тег, измените импорт 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.info(data);
}
</script>
</head>
<body>
<script type = "text/javascript">
draw(12);
</script>
</body>
</html>
Ваш HTML недействителен. Вам не хватает
</script>.