7d5431d8
梁灏
update some style
|
1
|
<template>
|
fdcb8143
梁灏
update Input load...
|
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
<Form ref="formCustom" :model="formCustom" :rules="ruleCustom" :label-width="80">
<FormItem label="Password" prop="passwd">
<Input type="password" v-model="formCustom.passwd"></Input>
</FormItem>
<FormItem label="Confirm" prop="passwdCheck">
<Input type="password" v-model="formCustom.passwdCheck"></Input>
</FormItem>
<FormItem label="Age" prop="age">
<Input type="text" v-model="formCustom.age" number></Input>
</FormItem>
<FormItem>
<Button type="primary" @click="handleSubmit('formCustom')">Submit</Button>
<Button type="ghost" @click="handleReset('formCustom')" style="margin-left: 8px">Reset</Button>
</FormItem>
<br><br>
|
509014fb
梁灏
update Icons
|
17
|
<Icon class="ivu-load-loop" type="ios-loading" size="14" color="#ff6600" />
|
9f45c24f
梁灏
change sync to lo...
|
18
|
|
509014fb
梁灏
update Icons
|
19
20
|
<Icon class="ivu-load-loop" type="ios-loading" size="12" color="#ff6600" />
<Icon class="ivu-load-loop" type="ios-loading" size="13" color="#ff6600" />
|
9f45c24f
梁灏
change sync to lo...
|
21
|
|
509014fb
梁灏
update Icons
|
22
23
24
25
26
|
<Icon class="ivu-load-loop" type="ios-loading" size="16" color="#ff6600" />
<Icon class="ivu-load-loop" type="ios-loading" size="18" color="#ff6600" />
<Icon class="ivu-load-loop" type="ios-loading" size="20" color="#ff6600" />
<Icon class="ivu-load-loop" type="ios-loading" size="30" color="#ff6600" />
<Icon class="ivu-load-loop" type="ios-loading" size="30" color="#ff6600" />
|
9f45c24f
梁灏
change sync to lo...
|
27
|
|
fdcb8143
梁灏
update Input load...
|
28
|
<Icon type="ios-alert" size="30" color="#ff6600" />
|
929fdf5c
梁灏
update loading icon
|
29
|
<Icon class="ivu-load-loop" type="ios-loading" size="30" color="#ff6600" />
|
fdcb8143
梁灏
update Input load...
|
30
|
</Form>
|
7d5431d8
梁灏
update some style
|
31
32
|
</template>
<script>
|
7d5431d8
梁灏
update some style
|
33
|
export default {
|
7d5431d8
梁灏
update some style
|
34
|
data () {
|
fdcb8143
梁灏
update Input load...
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
const validatePass = (rule, value, callback) => {
if (value === '') {
callback(new Error('Please enter your password'));
} else {
if (this.formCustom.passwdCheck !== '') {
// 对第二个密码框单独验证
this.$refs.formCustom.validateField('passwdCheck');
}
callback();
}
};
const validatePassCheck = (rule, value, callback) => {
if (value === '') {
callback(new Error('Please enter your password again'));
} else if (value !== this.formCustom.passwd) {
callback(new Error('The two input passwords do not match!'));
} else {
callback();
}
};
const validateAge = (rule, value, callback) => {
if (!value) {
return callback(new Error('Age cannot be empty'));
}
// 模拟异步验证效果
setTimeout(() => {
if (!Number.isInteger(value)) {
callback(new Error('Please enter a numeric value'));
} else {
if (value < 18) {
callback(new Error('Must be over 18 years of age'));
} else {
callback();
}
}
}, 1000);
};
|
7d5431d8
梁灏
update some style
|
73
|
return {
|
fdcb8143
梁灏
update Input load...
|
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
formCustom: {
passwd: '',
passwdCheck: '',
age: ''
},
ruleCustom: {
passwd: [
{ validator: validatePass, trigger: 'blur' }
],
passwdCheck: [
{ validator: validatePassCheck, trigger: 'blur' }
],
age: [
{ validator: validateAge, trigger: 'blur' }
]
}
}
},
methods: {
handleSubmit (name) {
this.$refs[name].validate((valid) => {
if (valid) {
this.$Message.success('Success!');
} else {
this.$Message.error('Fail!');
}
})
},
handleReset (name) {
this.$refs[name].resetFields();
|
0f822c9b
梁灏
add Input component
|
104
|
}
|
7d5431d8
梁灏
update some style
|
105
106
|
}
}
|
fc7ef072
梁灏
support Input
|
107
|
</script>
|