docs(Form): add async validation document

This commit is contained in:
陈嘉涵
2020-02-12 17:27:29 +08:00
parent 8e9e0af17d
commit 57d59e8a86
3 changed files with 68 additions and 28 deletions

View File

@@ -61,7 +61,7 @@ export default {
phone: [
{ required: true, message: this.$t('requirePhone') },
{
validator: val => /1\d{10}/.test(val),
validator: this.validatePhone,
message: this.$t('incorrectPhone'),
},
],
@@ -76,6 +76,10 @@ export default {
},
methods: {
validatePhone(val) {
return /1\d{10}/.test(val);
},
validateCode(val) {
return new Promise(resolve => {
this.$toast.loading(this.$t('validating'));