JavaScript/react/React.RefObject:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
创建页面,内容为“== 引言 == == error == * https://stackoverflow.com/questions/64524095/to-create-and-send-react-refobject-as-prop”
 
Kangkk​(留言 | 贡献)
 
(未显示同一用户的1个中间版本)
第1行: 第1行:
== 引言 ==
== 引言 ==
React.createRef 创建的类型,只读不可改。
== 示例 ==
=== 示例一 ===
<syntaxhighlight lang="javascript">
  ...
  dateWrap: React.RefObject<HTMLDivElement>;
  constructor(props: DateProps){
    super(props)
    this.dateWrap= React.createRef();
    this.state = {
      ...
    }
  }
...</syntaxhighlight>


== error ==
== error ==
* https://stackoverflow.com/questions/64524095/to-create-and-send-react-refobject-as-prop
* https://stackoverflow.com/questions/64524095/to-create-and-send-react-refobject-as-prop