react 子元素調用父元素的方法

父元素的方法:

 getClusterList = () => {
    this.props.setTableData(instance.get('/後臺地址', { params: { pageNum: this.pageNum, pageSize: this.pageSize } }));
  }

父元素使用子元素時代碼:

                <ClusterEdit clusterId={record.id} ref={(c) => { this.child = c; }} onRef={this.onRef} getClusterList={this.getClusterList}/>

子元素使用時代碼:

 this.props.getClusterList();

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章