react 子组件访问父组件的方法

  1. 回调函数(推荐)
    地址:https://ourcodeworld.com/articles/read/409/how-to-update-parent-state-from-child-component-in-react
  2. 获得父组件的实例(不推荐)
    var parent = this._reactInternalInstance._currentElement._owner._instance;
    地址:https://stackoverflow.com/questions/34257665/is-there-any-way-to-access-the-parent-component-instance-in-react

posted on 2018-05-21 17:58  cag2050  阅读(319)  评论(0编辑  收藏  举报

导航