index.vue
879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<template>
<el-form ref="form" :model="model" class="z-form" v-bind="$attrs">
<slot v-if="$slots.row" name="row"></slot>
<el-row v-else v-bind="row">
<slot></slot>
</el-row>
</el-form>
</template>
<script>
export default {
name: 'Form',
props: {
value: Object,
model: Object,
row: {
type: Object,
default() {
return {};
},
},
span: [Number, String],
itemComponent: String,
},
provide() {
return {
zForm: this,
};
},
methods: {
validate(callback) {
return this.$refs.form.validate(callback);
},
validateField(props, callback) {
return this.$refs.form.validateField(props, callback);
},
resetFields() {
this.$refs.form.resetFields();
},
clearValidate(props) {
return this.$refs.form.clearValidate(props);
},
},
};
</script>