import React, { Component } from "react";
export class TestHanderClick extends Component {
constructor(props) {
super(props);
this.state = {
cont: "内容哦",
};
}
//时时获取input中的值,通过事件onChange;e.target.value来获取值
changeCont(e) {
this.setState({
cont: e.target.value,
});
}
render() {
return (
<div>
<input
type="text"
value={this.state.cont}
onChange={this.changeCont.bind(this)}
/>
<p>{this.state.cont}</p>
</div>
);
}
}
export default TestHanderClick;
获取表单中的值还可以参考这篇文章https://www.cnblogs.com/IwishIcould/p/11619473.html