ant-design-vue/components/vc-form/demo/promise-validate.js

31 lines
628 B
JavaScript
Raw Normal View History

2019-01-12 03:33:27 +00:00
import { createForm } from '../index';
2019-01-01 08:25:50 +00:00
const Form = {
methods: {
2019-01-12 03:33:27 +00:00
handleSubmit(e) {
e.preventDefault();
const { validateFields } = this.form;
2019-01-01 08:25:50 +00:00
validateFields()
.then(console.log)
2019-01-12 03:33:27 +00:00
.catch(console.error);
2019-01-01 08:25:50 +00:00
},
},
2019-01-12 03:33:27 +00:00
render() {
const { getFieldDecorator } = this.form;
2019-01-01 08:25:50 +00:00
return (
<form onSubmit={this.handleSubmit}>
{getFieldDecorator('name', {
2019-01-12 03:33:27 +00:00
rules: [
{
required: true,
},
],
})(<input />)}
<button type="submit">submit</button>
2019-01-01 08:25:50 +00:00
</form>
2019-01-12 03:33:27 +00:00
);
2019-01-01 08:25:50 +00:00
},
2019-01-12 03:33:27 +00:00
};
2019-01-01 08:25:50 +00:00
2019-01-12 03:33:27 +00:00
export default createForm()(Form);