@form-create/ant-design-vue
Version:
ant-design-vue动态表单|form-create is a form generation component that can generate dynamic rendering, data collection, verification and submission functions through JSON. Supports 3 UI frameworks, and supports the generation of any Vue components. Built-in 2
23 lines (16 loc) • 504 B
JavaScript
import moment from 'moment';
const toMoment = function (val, format) {
return val instanceof moment ? val : moment(val, format);
};
function getFormat(ctx) {
return ctx.prop.props.format || (ctx.el ? ctx.el.format : '') || 'HH:mm:ss';
}
export default {
name: 'timePicker',
toFormValue(value, ctx) {
return value ? toMoment(value, getFormat(ctx)) : null;
},
toValue(formValue, ctx) {
return formValue ? formValue.format(getFormat(ctx)) : formValue;
},
}