-3

尝试从 Elm 教程编译 Pong 时出现错误“找不到变量 Text.color”

textGreen = rgb 160 200 160
txt f = leftAligned << f << monospace << Text.color textGreen << toText
msg = "SPACE to start, WS and &uarr;&darr; to move"

该错误是指在我尝试设置 Text.color 的位置提供的第二行。提前感谢您提供的任何帮助。

4

1 回答 1

1

你有Text进口吗?import Text您列出的代码将编译。

你的txt函数真的是你期望的类型吗?

> txt f = leftAligned << f << monospace << Text.color textGreen << toText`
<function> : (Text.Text -> Text.Text) -> String -> Graphics.Element.Element

如果是这样,这将编译并运行:

import Text             exposing (monospace, fromString)
import Color            exposing (rgb)
import Graphics.Element exposing (leftAligned)

textGreen = rgb 160 200 160
txt f = leftAligned << f 
                    << monospace 
                    << Text.color textGreen 
                    << fromString
msg = "SPACE to start, WS and &uarr;&darr; to move"

main = txt identity msg
于 2014-10-17T10:52:24.097 回答