尝试从 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 的位置提供的第二行。提前感谢您提供的任何帮助。
尝试从 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 的位置提供的第二行。提前感谢您提供的任何帮助。
你有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