mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-05 05:28:20 +08:00
23 lines
514 B
TypeScript
23 lines
514 B
TypeScript
import assign from 'object-assign';
|
|
const ValueMixin = {
|
|
setValue(field, e) {
|
|
let v = e;
|
|
const target = e && e.target;
|
|
if (target) {
|
|
if ((`${target.nodeName}`).toLowerCase() === 'input' &&
|
|
target.type === 'checkbox') {
|
|
v = target.checked;
|
|
} else {
|
|
v = e.target.value;
|
|
}
|
|
}
|
|
const newFormData = {};
|
|
newFormData[field] = v;
|
|
this.setState({
|
|
formData: assign({}, this.state.formData, newFormData),
|
|
});
|
|
},
|
|
};
|
|
|
|
export default ValueMixin;
|