1)redux状态管理
2)通过refs传递,代码如下所示:
父组件代码:
<
QueryBox
ref=
"queryBox"
app=
{this.
app
}
onSearch=
{this.
onSearch
}
onCount=
{this.
onCount
}
/>
let
QueryBoxInstance =
this.
refs.
queryBox
as
QueryBox;
QueryBoxInstance.
onChange();
3)通过回掉函数传递,代码如下:
父组件
<
AddModal
onOk=
{(
score:
any,
review:
any)
=>
this.
handleOk(
score,
review)
as
any
}
onCancel=
{this.
hideModal
as
any
}
loading=
{this.
state.
loading
}
studentInfo=
{this.
state.
studentInfo
}
/>
子组件
<
Modal
visible=
{true}
title=
"评分"
onOk=
{()
=>{
this.
props.
onOk(
this.
state.
score,
this.
state.
review)
}
}
onCancel=
{this.
props.
onCancel
}
confirmLoading=
{this.
props.
loading
}
okText=
"确认"
className=
"review"
cancelText=
"取消"
>