export default class Fz extends Component {
constructor(props) {
super(props);
this.MyRef = React.createRef()
}
handleClick=_=>{
console.log(this.MyRef.current.value)
}
render() {
return (
<div>
<input type="text" ref={this.MyRef}/>
<Button onClick={this.handleClick}>获取</Button>
</div>
)
}
}
ref获取DOM
最新推荐文章于 2024-08-30 15:48:49 发布