如何在Elm 0.17中使用onWithOptions?
我有一个选择一些状态的应用程序。最初,我有一个这样的代码如何在Elm 0.17中使用onWithOptions?,elm,Elm,我有一个选择一些状态的应用程序。最初,我有一个这样的代码 div [ classList [ onClick (SelectStatus (Just status)) ] 但在某个时刻,我需要停止事件传播。我发现有一个函数,但我不知道如何使用它。特别是解码器的参数是什么。我把它改写成这个表格,但还是有一些错误 div [ onWithOptions "click" { stopPropagation = True, preventDefault = False } ke
div
[ classList
[ onClick (SelectStatus (Just status)) ]
但在某个时刻,我需要停止事件传播。我发现有一个函数,但我不知道如何使用它。特别是解码器的参数是什么。我把它改写成这个表格,但还是有一些错误
div
[ onWithOptions "click" { stopPropagation = True, preventDefault = False } keyCode (SelectStatus (Just status))
这是错误消息
Function `onWithOptions` is expecting 3 arguments, but was given 4.
Maybe you forgot some parentheses? Or a comma?at line 171 col 11
您的链接指向从Elm 0.17开始的过时软件包。以下是正确的版本: 我认为这将为您提供您想要的功能:
onWithOptions "click" { stopPropagation = True, preventDefault = False } (Json.succeed (SelectStatus (Just status)))
该死的谷歌,我拿到了它给我的第一个链接。它看起来很值得信赖。非常感谢你。