【发布时间】:2018-09-25 16:23:55
【问题描述】:
我正在尝试创建一个简单的 Elm 项目,它只插入“hello world!”将字符串转换为 div。
这是我的代码:
index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>ELM Course</title>
</head>
<body>
<div id="hello-world"></div>
<script src="hello.js"></script>
<script>
const myDiv = document.getElementById("hello-world");
const app = Elm.Hello.embed(myDiv);
</script>
</body>
</html>
src/Hello.elm
module Hello exposing (..)
import Html exposing (text)
main =
text "Hello world!"
然后我使用以下命令编译 javascript:
elm make src/Hello.elm --output=hello.js
当我尝试使用浏览器打开 index.html 时出现问题,我收到此错误:
TypeError: Elm.Hello.embed is not a function
【问题讨论】:
标签: elm