在 tsx 中使用 react 的 ref 属性

函数组件

const myRef = React.useRef<HTMLDivElement>(null);
return <div ref={myRef} />;

参考:1
参考:2

你可能感兴趣的:(react,typescript,前端)