原文: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