获得子组件数据我有一个反应成分象下面这样:阵营:从父
<Parent>
<Child />
<button type="button" />
</Parent>
<Child />
中有一个input[type="file"]
表单控件。
当我点击<Parent />
按钮,我要上传的<Child />
与阿贾克斯的文件,
我怎么能访问内部<Child />
的input[type="file"]
?
我尝试使用refs
<Parent>
<Child ref="child"/>
<button type="button" />
</Parent>
,这样我可以通过写
this.refs.child.refs.file
访问input
,但我不认为这是最好的做法....
你的情况,你不需要'getInitialState'在'Child'组件 –