Model Elm create Elm app Error:初始化时为Elm程序指定的标志有问题。Json.Decode.oneOf在以下两种情况下失败
我正在开发一个elm应用程序,当我试图将Model Elm create Elm app Error:初始化时为Elm程序指定的标志有问题。Json.Decode.oneOf在以下两种情况下失败,model,elm,flags,Model,Elm,Flags,我正在开发一个elm应用程序,当我试图将模型更改为{}以外的任何东西时,我得到了错误 Error: Problem with the flags given to your Elm program on initialization. Json.Decode.oneOf failed in the following 2 ways: (1) Problem with the given value: undefined Expecting null (2) Problem with the gi
模型
更改为{}
以外的任何东西时,我得到了错误
Error: Problem with the flags given to your Elm program on initialization. Json.Decode.oneOf failed in the following 2 ways: (1) Problem with the given value: undefined Expecting null (2) Problem with the given value: undefined Expecting an INT
该错误被复制该错误是因为
init
预期可能是模型
,但在Ellie的HTML部分中,您没有传递标志
有两个选项,您可以处理标志,也可以删除标志
要保留解析标志:
您需要将Elm.Main.init({node:document.querySelector('Main')})更改为
这样可以处理无效或丢失的标志
删除标志解析
通常的方法是使用单元类型()
。
所以你的主要任务是
main : Program () Model Msg
及
初始化成为
init : () -> ( Model, Cmd Msg )
错误是因为
init
期望可能是Model
,但在Ellie的HTML部分中,您没有传递标志
有两个选项,您可以处理标志,也可以删除标志
要保留解析标志:
您需要将Elm.Main.init({node:document.querySelector('Main')})更改为
这样可以处理无效或丢失的标志
删除标志解析
通常的方法是使用单元类型()
。
所以你的主要任务是
main : Program () Model Msg
及
初始化成为
init : () -> ( Model, Cmd Msg )