任何人都知道是否有一种方法可以使用Stylish-elephants(或style-element v5)以编程方式将焦点设置在Element.Input.text
元素上?
答案 0 :(得分:3)
elm-package.json中需要“elm-lang / dom”:“1.1.1< = v< 2.0.0”
import Dom exposing (focus)
update msg model =
case msg of
FocusOn id ->
{ model | current_focus_id = id } ! [ Task.attempt FocusResult (focus (id)) ]
FocusResult result ->
case result of
Err (Dom.NotFound id) ->
model ! [ YourMsg]
Ok () ->
model ! []
view model = Element.layout [] <| el [onClick <| (FocusOn "id01")] (text "click here")