mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
37 lines
563 B
JavaScript
37 lines
563 B
JavaScript
// Utils
|
|
import { createNamespace } from '../utils';
|
|
|
|
const [createComponent, bem] = createNamespace('form');
|
|
|
|
export default createComponent({
|
|
provide() {
|
|
return {
|
|
vanForm: this,
|
|
};
|
|
},
|
|
|
|
data() {
|
|
return {
|
|
fields: [],
|
|
};
|
|
},
|
|
|
|
methods: {
|
|
onSubmit(event) {
|
|
event.preventDefault();
|
|
|
|
const results = this.fields.map(item => item.validate());
|
|
|
|
console.log(results);
|
|
},
|
|
},
|
|
|
|
render() {
|
|
return (
|
|
<form class={bem()} onSubmit={this.onSubmit}>
|
|
{this.slots()}
|
|
</form>
|
|
);
|
|
},
|
|
});
|