父组件清空子组件的内容 报错 _this.refs.child.handleReset is not a function
问题出在子组件的handleReset()方法
通过 console.log(this.refs.child); 没有发现子组件有handleReset(), 直接调用resetFields()
子组件:
handleReset(){
this.props.form.resetFields();
this.msgSearch() ;
}
父组件: return (
<div style={{padding:'10px'}}>
<AdvancedSearchForm msgListQuery={this.msgListQuery.bind(this)} ref="child" />
<Table
columns={columns}
dataSource={data}
pagination={false}
/>
<Button title="点击测试" onClick={this.clearButton}>
父控件调用子控件的方法
</Button>
<Pagination style={{"float":"right","marginTop":"10px"}} defaultCurrent={this.state.curPage} pageSize={this.state.msgPageSize} total={this.state.msgDataCount} onChange={this.pageChange.bind(this)}/>
</div>
);
// 测试
clearButton = () => {
console.log(this.refs.child);
this.refs.child.resetFields();
//this.refs.child.handleReset();
}