首页 > TAG信息列表 > parentRef

React中父组件获取子组件数据的3中方式

一、类组件的情况下 1、定义父组件(直接使用ref) export default class UserRef1 extends Component { constructor(props) { super(props); this.child = React.createRef(); } focus = () => { console.log(this.child.current.inputRef.current.value);