Elm 将文本内容放在容器的中间 我使用拼贴画,让元素放在盒子的中间。 import Graphics.Element exposing (show) import Graphics.Collage exposing (collage) textBox = show "hello world" main = collage 1000 1000 [textBox]
但最后一行有一个类型不匹配错误Elm 将文本内容放在容器的中间 我使用拼贴画,让元素放在盒子的中间。 import Graphics.Element exposing (show) import Graphics.Collage exposing (collage) textBox = show "hello world" main = collage 1000 1000 [textBox],elm,Elm,但最后一行有一个类型不匹配错误 Graphics.Element.Element Graphics.Collage.Form 因为,show函数返回元素,而拼贴只接受表单。我可以使用什么其他功能来将文本内容定位在拼贴< /代码>?< /p> 中。您可以将元素转换成具有图形的窗体。拼贴。 toForm : Element -> Form 你的程序只是变得简单 main = collage 1000 1000 [toForm textBox] grumpyjames的答案是正确的,将元
Graphics.Element.Element
Graphics.Collage.Form
因为,
show
函数返回元素
,而拼贴
只接受表单
。我可以使用什么其他功能来将文本内容定位在<代码>拼贴< /代码>?< /p> 中。您可以将元素转换成具有图形的窗体。拼贴。
toForm : Element -> Form
你的程序只是变得简单
main = collage 1000 1000 [toForm textBox]
grumpyjames的答案是正确的,将
元素
转换为形式
,将它们放在拼贴上。我只想指出,你不需要用拼贴把元素
放在中间。Graphics.Element
软件包的功能与拼贴功能类似,但它使用的是Element
而不是Form
。所以你也可以做:
import Graphics.Element exposing (..)
main =
container 1000 1000 middle (show "Hello, World!")
拼贴vs container。。。这其实是我脑海中的一个问题。。。我很高兴,你回答了。。谢谢你,罗伯特