如何在 Elm 0.17 中使用 onWithOptions?
How to use onWithOptions in Elm 0.17?
我有一个应用程序,我要在其中选择一些状态。最初,我有这样的代码
div
[ classList
[ onClick (SelectStatus (Just status)) ]
但在某些时候,我需要停止事件传播。我发现有一个 onWithOptions 功能,但我不知道如何使用它。特别是什么是解码器参数。我将其重写为这种形式,但仍然出现一些错误。
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
您的 link 指向 Elm 0.17 的过时包。这是正确的版本:http://package.elm-lang.org/packages/elm-lang/html/1.1.0/Html-Events#onWithOptions
我认为这将为您提供所需的功能:
onWithOptions "click" { stopPropagation = True, preventDefault = False } (Json.succeed (SelectStatus (Just status)))
我有一个应用程序,我要在其中选择一些状态。最初,我有这样的代码
div
[ classList
[ onClick (SelectStatus (Just status)) ]
但在某些时候,我需要停止事件传播。我发现有一个 onWithOptions 功能,但我不知道如何使用它。特别是什么是解码器参数。我将其重写为这种形式,但仍然出现一些错误。
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
您的 link 指向 Elm 0.17 的过时包。这是正确的版本:http://package.elm-lang.org/packages/elm-lang/html/1.1.0/Html-Events#onWithOptions
我认为这将为您提供所需的功能:
onWithOptions "click" { stopPropagation = True, preventDefault = False } (Json.succeed (SelectStatus (Just status)))