Q: 人員列表頁面切換保留篩選項
ans:
/**
* 表單組件在掛載時,將組件的 fields 值賦給對應的交互組件
*/
componentDidMount() {
const { fields, pageIndex } = View;
this.props.form.setFieldsValue(fields);
this.getUser(pageIndex);
}
/**
* 表單組件在卸載時,將對應的交互組件的值賦給組件的 fields
*/
componentWillUnmount() {
View.fields = this.props.form.getFieldsValue();
View.pageIndex = this.state.pageIndex;
}
可以保留所有篩選項以及當前pageIndex等。在組件卸載的時候,都是存儲在View當前的實例上。在組件重新加載的時候,又設置當前form的值,以及傳遞當前pageIndex。
記錄一下~