我正在尝试添加订阅,因为我有一个下拉列表,这有助于确保当您在下拉列表之外单击时自动关闭。这样做时,我不得不改变model
我的update
.
此链接(将带您到 Elm Bootstrap 站点)是我正在使用的下拉菜单,它使用的是 Bootstrap 4。
我得到的错误
第一个论点
sandbox
不是我所期望的:295| Browser.sandbox 296|> { init = initialModel 297|>
, update = update 298|> , view = view 299|> }这个参数是一个类型的记录:
{ init : ( Model, Cmd Msg ) , update : Msg -> Model -> ( Model, Cmd Msg ) , view : Model -> Html Msg }
但
sandbox
需要第一个论点是:{ init : ( Model, Cmd Msg ) , update : Msg -> ( Model, Cmd Msg ) -> ( Model, Cmd Msg ) , view : ( Model, Cmd Msg ) -> Html Msg }
别名模型
type alias Model =
{ currentNumber : Int, clicks : Int, outputList : List(String), uniqueValues : Dict Int Int, firstNumber : String, secondNumber : String, myDropState : Dropdown.State, items : List String, selectedItem : String, dictKeyToRemove : String,
modalVisibility : Modal.Visibility }
初始模型
initialModel : (Model, Cmd Msg)
initialModel =
({ currentNumber = 0, clicks = 0, outputList = [""], uniqueValues = Dict.empty, firstNumber = "", secondNumber = "", myDropState = Dropdown.initialState, items = ["Small", "Medium", "Large"], selectedItem = "Small", dictKeyToRemove = "",
modalVisibility = Modal.hidden }, Cmd.none)
主要的
main : Program () Model Msg
main =
Browser.sandbox
{ init = initialModel
, update = update
, view = view
}
订阅
subscriptions : Model -> Sub Msg
subscriptions model =
Sub.batch
[ Dropdown.subscriptions model.myDropState DropMsg ]
更新
update : Msg -> Model -> ( Model, Cmd Msg)
update msg model =
case msg of
DropMsg state ->
({model | myDropState = state }, Cmd.none)
我不确定此时我缺少什么,我尝试改变论点但没有运气。