为什么我不能在榆木0.19中使用`onWithOptions`

bre*_*son 6 elm

我试图将elm应用程序从0.18升级到0.19.

我遇到了这个错误 -

Detected errors in 1 module.                                         
-- BAD IMPORT ---------------------------------------- src/Views/Interaction.elm

The `Html.Events` module does not expose `onWithOptions`:

13| import Html.Events exposing (onWithOptions)
                                 ^^^^^^^^^^^^^
These names seem close though:

    onMouseEnter
    onMouseLeave
    onMouseOut
    onMouseOver
Run Code Online (Sandbox Code Playgroud)

文件显示,onWithOptions应该可用.

我的代码是

module Views.Interaction exposing (onClickNoBubble)

{-| Helper functions for page interactions.


# Helpers

@docs onClickNoBubble

-}

import Html
import Html.Events exposing (onWithOptions)
import Json.Decode as Decode


{-| Replicates the onClick function but prevents bubbling
-}
onClickNoBubble : msg -> Html.Attribute msg
onClickNoBubble message =
    onWithOptions "click" { stopPropagation = True, preventDefault = True } (Decode.succeed message)
Run Code Online (Sandbox Code Playgroud)

我该如何前进?

gle*_*nsl 16

榆木0.19不使用elm-lang/html.你正在阅读错误的文档.它被替换为elm/html具有custom用于相同目的的功能:

onClickNoBubble : msg -> Html.Attribute msg
onClickNoBubble message =
    Html.Events.custom "click" (Decode.succeed { message = message, stopPropagation = True, preventDefault = True })
Run Code Online (Sandbox Code Playgroud)