原文:react hooks 使用useRef父组件调用子组件方法

githup源代码 https: github.com shengbid antprov blob master src pages product addProduct index.tsx 使用场景: 一个form表单组件,提交按钮在父组件,点击时要调用子组件方法获取子组件数据 child.tsx子组件 主要用到forwardRef传递子组件useImperativeHandle暴露定义的组件 ...

2021-07-04 19:52 0 489 推荐指数:

查看详情

React Hooks组件调用组件方法

React Hooks组件调用组件方法 使用到的hooks-- useImperativeHandle,useRef /* child组件 */ // https://reactjs.org/docs ...

Thu Oct 10 22:11:00 CST 2019 1 7385
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM