Closed martinwithyou closed 6 years ago
见很少。。。
const Filter = ({ onAdd, isMotion, switchIsMotion, onFilterChange, filter, form: { getFieldDecorator, getFieldsValue, setFieldsValue, }, }) => {
console.log(getFieldDecorator);
console.log(getFieldsValue);
console.log(setFieldsValue);
const handleFields = (fields) => { const { createTime } = fields if (createTime.length) { fields.createTime = [createTime[0].format('YYYY-MM-DD'), createTime[1].format('YYYY-MM-DD')] } return fields }
const handleSubmit = () => { let fields = getFieldsValue() fields = handleFields(fields) onFilterChange(fields) }
const handleReset = () => { const fields = getFieldsValue() for (let item in fields) { if ({}.hasOwnProperty.call(fields, item)) { if (fields[item] instanceof Array) { fields[item] = [] } else { fields[item] = undefined } } } setFieldsValue(fields) handleSubmit() }
const handleChange = (key, values) => { let fields = getFieldsValue() fields[key] = values fields = handleFields(fields) onFilterChange(fields) }
const { name, address } = filter
let initialCreateTime = [] if (filter.createTime && filter.createTime[0]) { initialCreateTime[0] = moment(filter.createTime[0]) } if (filter.createTime && filter.createTime[1]) { initialCreateTime[1] = moment(filter.createTime[1]) }
return (
) }
Filter.propTypes = { onAdd: PropTypes.func, isMotion: PropTypes.bool, switchIsMotion: PropTypes.func, form: PropTypes.object, filter: PropTypes.object, onFilterChange: PropTypes.func, }
export default Form.create()(Filter)
这个就是你 user 文件夹 下面的 filter.js这么写的啊、、、、、
const Filter = ({ onAdd, isMotion, switchIsMotion, onFilterChange, filter, form: { getFieldDecorator, getFieldsValue, setFieldsValue, }, }) => {
it belongs to you.
。。。。。。 可能我对于函数参数的理解,是 “”父组件的传的值“” 得结构赋值。
难道不是?
form: { getFieldDecorator, getFieldsValue, setFieldsValue, },