简体   繁体   中英

Syntax confusion in Fable with EventTarget

I'm new to Fable/Elmish/React, and I'm trying to understand the syntax to cast an EventTarget so I can get to the .value

The examples I can find all use the

input [ Value model.Value
          OnChange (fun ev -> ev.target?value |> string
         ]

However I get

None of the types 'EventTarget, string' support the operator '?'

Instead I have to use the following syntax

input [ Value model.Value
          OnChange (fun ev -> (ev.target:?> HTMLInputElement ).value
         ]

So what gives? Am I referencing different assemblies?

You need to

open Fable.Core.JsInterop

to see the operator ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM