【发布时间】:2021-01-08 07:41:17
【问题描述】:
我有一个输入,我只想使用 ref 更新(不使用 setState)。 构造函数(道具){ 超级(道具);
this.Increase = this.Increase.bind(this)
this.textInput = React.createRef();
this.state = {
inputVal: -1
};
}
<div>
<input type="number" ref={textInput} placeholder="count"/>
<span onClick={this.Increase}>Increase
</span>
</div>
我有一个函数可以用来增加输入值
Increase(event){
//access ref here and update input value using ref
}
任何帮助将不胜感激。
谢谢
【问题讨论】:
标签: reactjs