Error: Target container is not a DOM element (when running Purescript Pux Program)

Error: Target container is not a DOM element (when running Purescript Pux Program)

我已经使用 Purescript 0.12.5 编译了 this program,但是当我在 Firefox 67.0.2 中查看 index.html 时,我在 Web 控制台中收到以下错误:

错误:目标容器不是 DOM 元素。 app.js:5160:15

这是 index.html 文件:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>PS3</title>   

<script src="https://unpkg.com/react@16/umd/react.production.min.js"
   crossorigin></script>
<script src="https://unpkg.com/react-dom@16/umd/react-   
   dom.production.min.js" crossorigin></script>

<script src='app.js'></script>
</head>
<body>
<div id="app"></div>

</body>
</html>

如有任何帮助,我们将不胜感激!

这是因为您在 之前 加载程序 <div id="app"> 元素,因此在程序 [=20] 时该元素尚不存在=] 并试图找到它。

尝试在 <div> 之后移动 <script> 标签:

<html>
<head>
  ...
</head>
<body>
  <div id="app"></div>
  <script src='app.js'></script>
</body>
</html>