相关疑难解决方法(0)

用Reactjs清除输入字段?

我在下面使用变量.

var newInput = {
   title: this.inputTitle.value,
   entry: this.inputEntry.value    
};
Run Code Online (Sandbox Code Playgroud)

这由我的输入字段使用.

<input type="text" id="inputname" className="form-control" ref={el => this.inputTitle = el} />   
<textarea id="inputage" ref={el => this.inputEntry = el} className="form-control" />
<button className="btn btn-info" onClick={this.sendthru}>Add</button>
Run Code Online (Sandbox Code Playgroud)

一旦我激活,{this.sendthru}我想清除我的输入字段.但是,我不确定该怎么做.

另外,如本例所示,有人指出我应该使用ref属性作为输入值.我不清楚的是它到底意味着什么{el => this.inputEntry = el}.el在这种情况下有什么意义?

javascript reactjs

30
推荐指数
6
解决办法
8万
查看次数

标签 统计

javascript ×1

reactjs ×1