ref

ref

1、Callback Refs

  最古老原始的,通过 ref={SetMethod} 来获取 ref的方法。

    

2、Creating Refs

  Callback refs 需要写很多 SetMethod,非常麻烦。最新的 React 已经推出了 Creating Refs,来减少 SetMethod 的编写。

  

  然后通 current 属性来引用。

  

参考:

1、https://reactjs.org/docs/refs-and-the-dom.html#creating-refs

原文地址:https://www.cnblogs.com/tekkaman/p/10127816.html