我正在尝试从此页面运行Elm输入示例.具体来说,文本字段示例,我收到一个错误,说该Graphics.Input模块丢失.
我在一个名为的文件中有这个Main.elm:
import Graphics.Input as Input
main = let (field, state) = Input.field "Type here!"
in lift2 display field state
display field state =
field `above` asText state
Run Code Online (Sandbox Code Playgroud)
如果我运行elm-server并导航到localhost:8000,我得到错误
Your browser may not be supported. Are you using a modern browser?
Runtime Error in Main module:
Error: Module 'Graphics.Input' is missing. Compile with --make flag or load missing module in a separate JavaScript file.
The problem may stem from an improper usage of:
Input.field, above
Run Code Online (Sandbox Code Playgroud)
编译项目elm --make Main.elm给了我
elm: Graphics/Input.elm: openFile: does not exist (No such file or directory)
Run Code Online (Sandbox Code Playgroud)
我需要做一些额外的安装Graphic.Input吗?
补充说明:
cabal install elm最近使用它安装它(2013年6月15日).当前版本已标记Elm-0.7.1.1.chromiumJS提示和闲逛,原来没有Elm.Graphics.Input的模块,但有是一个Elm.Input.没有一个被调用的函数field,有一个类似的看起来被称为textField,但它不是简单的可互换的.运行这个:
import Input
main = let (field, state) = textField "Type here!"
in lift2 display field state
display field state =
field `above` asText state
Run Code Online (Sandbox Code Playgroud)
给了我错误
Your browser may not be supported. Are you using a modern browser?
Runtime Error in Main module:
TypeError: a is undefined
The problem may stem from an improper usage of:
above
Run Code Online (Sandbox Code Playgroud)
The Graphics.Input package is new in version 0.8. So, since you're running version 0.7, that explains your problem.
0.8 was released somewhat recently, but it's definitely been out longer than June 15th, so you probably just forgot to cabal update before installing it. Running cabal update now and then updating elm to 0.8 should fix your issue.