父组件代码:
// 数据
state = {
params: {},
};
// 方法
handleSearch = params => {
this.setState({ params });
};
// 引用子组件
render() {
const code = 'report';
return (
<Grid
code={code}
onSearch={this.handleSearch}
/>
)
}
子组件代码:
// 方法
refreshTable = (firstPage = false) => {
// 父组件传过来的方法和参数,好像都是props里拿
const { onSearch,code} = this.props;
console.log(code);
const params = { };
if (onSearch) {
onSearch(params);
}
};