使用时 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/