【发布时间】:2017-07-31 01:59:19
【问题描述】:
我正在尝试清除焦点上的输入的 defaultValue,但内联或在外部函数中都遇到了麻烦。想到最好的方法来做到这一点?如果我使用 value 而不是 defaultValue 这是同样的问题。
const SomeComponent = (inputValue) => {
<input type="text"
defaultValue={inputValue}
onFocus = // clear input defaultValue
onBlur={() => dosomething()}/>
}
export default SomeComponent
【问题讨论】:
-
您编写的代码不起作用。您需要一个带有花括号的
return内部函数。 -
SomeComponent是无状态组件吗?
标签: reactjs input redux onfocus