// 使用React语法如下
constructor (props) {
super(props);
this.ref1 = React.createRef();
this.ref2 = React.createRef();
}
<ChildComponent1 ref={this.ref1} />
<ChildComponent2 ref={this.ref2} />
// 输入this.ref1.current可以得到ChildComponent1内state的值, 这样父组件就能获取到子组件了
父组件如何获取子组件的state的值
最新推荐文章于 2024-06-20 20:20:21 发布