当尝试从Elm教程编译Pong时,我收到错误"找不到变量Text.color"
textGreen = rgb 160 200 160
txt f = leftAligned << f << monospace << Text.color textGreen << toText
msg = "SPACE to start, WS and ↑↓ to move"
错误是指我尝试设置Text.color时提供的第二行。 提前感谢您提供的任何帮助。
答案 0 :(得分: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 ↑↓ to move"
main = txt identity msg