import React, {Component} from 'react';
class InputTest extends Component {
constructor(props) {
super(props);
this.state = {
val:''
}
}
render() {
return (
<div>
<input type="text" onChange={(event)=>{
console.log(event.target.value)
this.setState({
val:event.target.value
})
}} />
<button onClick={()=>{
}}>哈哈</button>
</div>
);
}
}
export default InputTest;
想要的效果