我试图创建一个简单的榆树项目,它只是插入“你好世界!”串成一个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发布于 2018-09-25 17:45:21
embed函数已被删除,以支持init。将const app行上的javascript更改为:
const app = Elm.Hello.init({ node: myDiv });https://stackoverflow.com/questions/52502732
复制相似问题