fixed Form reset using Input or Switch
fixed Form reset using Input or Switch
This commit is contained in:
parent
867eca350e
commit
38646a1171
2 changed files with 24 additions and 23 deletions
|
@ -189,7 +189,7 @@
|
||||||
if (Array.isArray(value) && value.length > 0) {
|
if (Array.isArray(value) && value.length > 0) {
|
||||||
this.validateDisabled = true;
|
this.validateDisabled = true;
|
||||||
prop.o[prop.k] = [];
|
prop.o[prop.k] = [];
|
||||||
} else if (value) {
|
} else if (value !== this.initialValue) {
|
||||||
this.validateDisabled = true;
|
this.validateDisabled = true;
|
||||||
prop.o[prop.k] = this.initialValue;
|
prop.o[prop.k] = this.initialValue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
<template>
|
<template>
|
||||||
<i-form v-ref:form-inline :model="formInline" :rules="ruleInline" inline>
|
<i-form v-ref:form-validate :model="formValidate" :rules="ruleValidate" :label-width="100">
|
||||||
<Form-item prop="user">
|
<Form-item label="输入框" prop="input">
|
||||||
<i-input type="text" :value.sync="formInline.user" placeholder="Username">
|
<i-input :value.sync="formValidate.input" placeholder="请输入"></i-input>
|
||||||
<Icon type="ios-person-outline" slot="prepend"></Icon>
|
|
||||||
</i-input>
|
|
||||||
</Form-item>
|
</Form-item>
|
||||||
<Form-item prop="password" :show-message="false">
|
<Form-item label="Ajax:" prop="ajax">
|
||||||
<i-input type="password" :value.sync="formInline.password" placeholder="Password">
|
<div slot="label">
|
||||||
<Icon type="ios-locked-outline" slot="prepend"></Icon>
|
<span>Ajax</span>
|
||||||
</i-input>
|
<Tooltip content="基于 axios">
|
||||||
|
<Icon type="ios-help" size="14" color="#3399ff"></Icon>
|
||||||
|
</Tooltip>
|
||||||
|
<span>:</span>
|
||||||
|
</div>
|
||||||
|
<Switch :checked.sync="formValidate.ajax"></Switch>
|
||||||
</Form-item>
|
</Form-item>
|
||||||
<Form-item>
|
<Form-item>
|
||||||
<i-button type="primary" @click="handleSubmit('formInline')">登录</i-button>
|
<i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
|
||||||
|
<i-button type="ghost" @click="handleReset('formValidate')" style="margin-left: 8px">重置</i-button>
|
||||||
</Form-item>
|
</Form-item>
|
||||||
</i-form>
|
</i-form>
|
||||||
</template>
|
</template>
|
||||||
|
@ -19,18 +23,12 @@
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
formInline: {
|
formValidate: {
|
||||||
user: '',
|
input: '123',
|
||||||
password: ''
|
ajax: true
|
||||||
},
|
},
|
||||||
ruleInline: {
|
ruleValidate: {
|
||||||
user: [
|
|
||||||
{ required: true, message: '请填写用户名', trigger: 'change' }
|
|
||||||
],
|
|
||||||
password: [
|
|
||||||
{ required: true, message: '请填写密码', trigger: 'blur' },
|
|
||||||
{ type: 'string', min: 6, message: '密码长度不能小于6位', trigger: 'change' }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -43,6 +41,9 @@
|
||||||
this.$Message.error('表单验证失败!');
|
this.$Message.error('表单验证失败!');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
handleReset (name) {
|
||||||
|
this.$refs[name].resetFields();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue