gpt4 book ai didi

javascript - 如何在 React.js 中正确捕获文本输入的 change/focusOut 事件?

转载 作者:IT王子 更新时间:2023-10-29 03:03:25 26 4
gpt4 key购买 nike

我有一个表单,我想在其中处理文本输入的 change 事件,但是 React onChangekey down 上触发(与原生 JS 相反,当输入字段失去焦点时触发 change 事件)。

是否有React 方式来做我想做的事?

最佳答案

如果你只想在输入失去焦点时触发验证,你可以使用 onBlur .

React uses onFocus and onBlur instead of onFocusIn and onFocusOut. All React events are normalized to bubble, so onFocusIn and onFocusOut are not needed/supported by React. 2

关于javascript - 如何在 React.js 中正确捕获文本输入的 change/focusOut 事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37609049/

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