fix: 解决props为空,验证表单没响应的问题
This commit is contained in:
parent
8a994e63bf
commit
9d85fdcdb3
2 changed files with 27 additions and 0 deletions
|
@ -169,6 +169,24 @@
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</Form>
|
</Form>
|
||||||
</i-col>
|
</i-col>
|
||||||
|
<i-col span="6">
|
||||||
|
<Form :model="formValidate5" ref="formValidate5">
|
||||||
|
<FormItem label="name" prop="name">
|
||||||
|
<Input v-model="formValidate5.name" placeholder="Enter your name"></Input>
|
||||||
|
</FormItem>
|
||||||
|
<FormItem label="name">
|
||||||
|
<i-switch v-model="formValidate5.msgCheck" />
|
||||||
|
</FormItem>
|
||||||
|
<FormItem label="msg" v-if="formValidate5.msgCheck" prop="msg" :rules="[{
|
||||||
|
required: true
|
||||||
|
}]" >
|
||||||
|
<Input v-model="formValidate5.msg" placeholder="msg"></Input>
|
||||||
|
</FormItem>
|
||||||
|
<FormItem>
|
||||||
|
<Button type="primary" @click="handleSubmit('formValidate5')">Submit</Button>
|
||||||
|
</FormItem>
|
||||||
|
</Form>
|
||||||
|
</i-col>
|
||||||
</row>
|
</row>
|
||||||
<div style="margin: 100px;width: 200px;">
|
<div style="margin: 100px;width: 200px;">
|
||||||
<Divider>普通组件</Divider>
|
<Divider>普通组件</Divider>
|
||||||
|
@ -284,6 +302,11 @@
|
||||||
rate: 3,
|
rate: 3,
|
||||||
colorPicker: ''
|
colorPicker: ''
|
||||||
},
|
},
|
||||||
|
formValidate5: {
|
||||||
|
name: '',
|
||||||
|
msgCheck: false,
|
||||||
|
msg: ''
|
||||||
|
},
|
||||||
ruleValidate: {
|
ruleValidate: {
|
||||||
name: [
|
name: [
|
||||||
{ required: true, message: 'The name cannot be empty', trigger: 'blur' }
|
{ required: true, message: 'The name cannot be empty', trigger: 'blur' }
|
||||||
|
|
|
@ -91,6 +91,10 @@
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
let valid = true;
|
let valid = true;
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
// fields 为空需要返回promise
|
||||||
|
if (this.fields.length === 0) {
|
||||||
|
resolve(valid);
|
||||||
|
}
|
||||||
this.fields.forEach(field => {
|
this.fields.forEach(field => {
|
||||||
field.validate('', errors => {
|
field.validate('', errors => {
|
||||||
if (errors) {
|
if (errors) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue