首页 > 解决方案 > 在文本输入下创建按钮时如何修复错误?

问题描述

我想在这两个文本输入下创建一个按钮。我刚刚超越了文档中的代码。但我得到这个错误:

div函数需要 2 个参数,但它得到了 5 个。

我该如何解决这个问题?

-- VIEW


view : Model -> Html Msg
view model =
  div []
    [ input [ placeholder  "Team 1", style "width" "300px", style "height" "30px", style "font-size" "25px", value model.content ] []
    , input [ placeholder  "Strength", style "width" "300px", style "height" "30px", style "font-size" "25px", value model.content ] []
    ]

  div []
    [ button [ style "color" "white", style "height" "60px", style "font-size" "30px", style "margin-right" "70px"]
    ]

标签: syntaxelm

解决方案


您的代码,省略了孩子,可以重新格式化为

div [] [ ... ] div [] [ ... ]

你明白为什么编译器认为你给出了div五个参数吗?

由于view应该返回单个元素,因此您必须将div's 包装在其他元素中,例如另一个div

div []
  [ div [] [ ... ]
  , div [] [ ... ]
  ]

推荐阅读