我目前正在学习 Elm,我知道这是一个菜鸟问题,但我似乎无法正确输入注释这个只返回纯 div 的函数。
header =
div [] [ text "Hello" ]
输入注释此函数的准确方法是什么?
最佳答案
正确的注释是这样的:
header : Html msg
header =
div [] [ text "Hello" ]
将来,你可以使用 Elm REPL 来查找某物的类型:
> import Html exposing (..)
> div [] [ text "Hello" ]
{ type = "node", tag = "div", facts = {}, children = {}, namespace = <internal structure>, descendantsCount = 0 }
: Html.Html msg
冒号后面的部分指定签名,即Html.Html msg
关于html - 不带参数的 View 函数的正确类型注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47720038/