馬老師 ID生成器與數(shù)據(jù)同步器
2022-10-27 12:30 作者:666好聽(tīng)的名字 | 我要投稿
const inputEle = useRef(null);
? ?const onButtonClick = () => {
? ? ? ?// current 指向已掛載到 DOM 上的文本輸入元素
? ? ? ?inputEle.current.focus();
? ?}
? ?return (
? ? ? ?<>
? ? ? ? ? ?<input ref={inputEle} type='text' />
? ? ? ? ? ?<button onClick={onButtonClick}>Focus the input</button>
? ? ? ?</>
標(biāo)簽: