尤川豪   ·  2年前
445 貼文  ·  275 留言

Elm 常見 type 觀察

type alias Html msg =
    Node msg

hello : Html msg
hello =
  div [] [ text "Hello!" ]
node : String -> List (Attribute msg) -> List (Html msg) -> Html msg

div : List (Attribute msg) -> List (Html msg) -> Html msg
div attributes children =
    node "div" attributes children
h1 : List (Attribute msg) -> List (Html msg) -> Html msg
h2 : List (Attribute msg) -> List (Html msg) -> Html msg
h3 : List (Attribute msg) -> List (Html msg) -> Html msg
h4 : List (Attribute msg) -> List (Html msg) -> Html msg
h5 : List (Attribute msg) -> List (Html msg) -> Html msg
h6 : List (Attribute msg) -> List (Html msg) -> Html msg

觀察以下兩個,都是符合的

  div [] [ text "Hello!" ]
  div []
    [ button [ onClick Decrement ] [ text "-" ]
    , div [] [ text (String.fromInt count) ]
    , button [ onClick Increment ] [ text "+" ]
    ]
  分享   共 494 次點閱
共有 0 則留言
還沒有人留言。歡迎分享您的觀點、或是疑問。
您的留言
尤川豪
445 貼文  ·  275 留言

Devs.tw 是讓工程師寫筆記、網誌的平台。隨手紀錄、寫作,方便日後搜尋!

歡迎您一起加入寫作與分享的行列!

查看所有文章