gpt4 book ai didi

reactjs - 试剂:component-did-mount

转载 作者:行者123 更新时间:2023-12-03 13:11:05 26 4
gpt4 key购买 nike

我正在尝试将初始焦点设置在输入元素上

(defn initial-focus-wrapper [element]
(with-meta element
{:component-did-mount #(.focus (reagent/dom-node %))}))

(defn chat-input []
(fn []
[initial-focus-wrapper
[:input {:type "text"}]]))

但这对我不起作用。我做错了什么?

最佳答案

正如 sbensu 所说,with-meta 似乎只在函数的试剂中起作用。这意味着它可以与 identity 一起使用来生成希望的可重用包装器

(def initial-focus-wrapper 
(with-meta identity
{:component-did-mount #(.focus (reagent/dom-node %))}))

(defn chat-input []
(fn []
[initial-focus-wrapper
[:input {:type "text"}]]))

关于reactjs - 试剂:component-did-mount,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27602592/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com