ReactJs 如何从父来源访问子公司的链接
如何访问父函数中的子项链接,在父功能中与它们进行操作?
class Parent extends Component {
someFunction//{
// how to access h1 element of child in here ??
}
render// {
return /
<child></child>
/;
}
}
class Child extends Component {
render// {
return /
<h1 ref="hello">Hello</h1>
/;
}
}
没有找到相关结果
已邀请:
3 个回复
三叔
赞同来自:
窦买办
赞同来自:
在您的情况下,子组件不会以您需要更改的大写字母开头。
[code]<script src="https://cdnjs.cloudflare.com/a ... gt%3B
<script src="https://cdnjs.cloudflare.com/a ... gt%3B
<divi id="app"></divi>
江南孤鹜
赞同来自:
, 制作一个组件
能够接收和确定
来自他的父母。
以下是此方法的文档:
https://reactjs.org/docs/forwarding-refs.html
但是如何在代码中实现它的示例:
https://reactjs.org/docs/forwarding-refs.html
我希望它会有所帮助。