//父组件的值变化(this.props.locationFileList),子组件的fileList 字段也跟着变
//子组件
componentDidMount() {
const { form: { setFieldsValue } } = this.props;
setFieldsValue({ fileList: fileListFun(this.props.locationFileList) });
}
//子组件
componentDidUpdate(prevProps: FormProps) {
const { form: { setFieldsValue } } = this.props;
// 这里用componentDidMount初始化渲染的值 与 父组件更新后的值对比
//不想等,就更新为父组件的值
if (prevProps.locationFileList !== this.props.locationFileList) {
setFieldsValue({ fileList: fileListFun(this.props.locationFileList) });
}
}