gpt4 book ai didi

debugging - 是否可以在使用 elm reactor 时显示 Elm 的调试器?

转载 作者:行者123 更新时间:2023-12-05 00:46:26 30 4
gpt4 key购买 nike

使用时 elm reactor ,它工作得很好,但似乎没有提供一种显示调试器的方法,以在每次更新后明确查看模型的状态。
elm reactor --debug不起作用,我在 UI 中没有看到选项,也没有在 the documentation 中看到它的提及.

我们可以在使用 elm reactor 时看到调试器吗? ?

这是在 Reactor 中运行但不显示调试器的代码示例(使用 Elm 0.19 时)

module Main exposing (main)

import Browser
import Html exposing (Html, button, div, text)
import Html.Events exposing (onClick)


type alias Model =
{ count : Int }


initialModel : Model
initialModel =
{ count = 0 }


type Msg
= Increment
| Decrement


update : Msg -> Model -> Model
update msg model =
case msg of
Increment ->
{ model | count = model.count + 1 }

Decrement ->
{ model | count = model.count - 1 }


view : Model -> Html Msg
view model =
div []
[ button [ onClick Increment ] [ text "+1" ]
, div [] [ text <| String.fromInt model.count ]
, button [ onClick Decrement ] [ text "-1" ]
]


main : Program () Model Msg
main =
Browser.sandbox
{ init = initialModel
, view = view
, update = update
}

最佳答案

elm reactor 不再包含调试器在 0.19。它在重构时显然已被删除(尽管将来可能会重新添加)。

现在,我建议使用 elm-live它还支持自动重新加载。

关于debugging - 是否可以在使用 elm reactor 时显示 Elm 的调试器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54103120/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com