gpt4 book ai didi

javascript - 文本区域值和文本属性在 react 中未定义

转载 作者:行者123 更新时间:2023-12-03 06:02:47 25 4
gpt4 key购买 nike

我有一个文本区域

<textarea ref="newText" defaultValue={this.props.children}></textarea>

我需要获取它的值,我这样尝试过。

this.props.update(this.refs.newText.value,this.props.index);

我还使用文本而不是值,但它仍然返回未定义。

this.refs.newText.value

最佳答案

尝试更新你的react-dom库。 ref 帮助您命令式修改子项,而无需使用 props。 get the latest from react docs


src="https://unpkg.com/react@15/dist/react.js">
src="https://unpkg.com/react-dom@15/dist/react-dom.js">

Check out Refs & the DOM

关于javascript - 文本区域值和文本属性在 react 中未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39685830/

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