diff --git a/docs/markdown/en-US/address-edit.md b/docs/markdown/en-US/address-edit.md index 413621337..e5842ed54 100644 --- a/docs/markdown/en-US/address-edit.md +++ b/docs/markdown/en-US/address-edit.md @@ -68,6 +68,7 @@ export default { | show-search-result | Whether to show address search result | `Boolean` | `false` | - | | is-saving | Whether to show save button loading status | `Boolean` | `false` | - | | is-deleting | Whether to show delete button loading status | `Boolean` | `false` | - | +| tel-validator | The method to validate tel | `(tel: string) => boolean` | - | - | ### Event diff --git a/docs/markdown/en-US/contact.md b/docs/markdown/en-US/contact.md index 26f8b9921..dedabda9e 100644 --- a/docs/markdown/en-US/contact.md +++ b/docs/markdown/en-US/contact.md @@ -161,6 +161,7 @@ export default { | is-edit | Whether is editing | `Boolean` | `false` | - | | is-saving | Whether to show save button loading status | `Boolean` | `false` | - | | is-deleting | Whether to show delete button loading status | `Boolean` | `false` | - | +| tel-validator | The method to validate tel | `(tel: string) => boolean` | - | - | ### ContactEdit Event diff --git a/docs/markdown/zh-CN/address-edit.md b/docs/markdown/zh-CN/address-edit.md index 284da50e8..ecdfdf24b 100644 --- a/docs/markdown/zh-CN/address-edit.md +++ b/docs/markdown/zh-CN/address-edit.md @@ -67,6 +67,7 @@ export default { | show-search-result | 是否显示搜索结果 | `Boolean` | `false` | - | | is-saving | 是否显示保存按钮加载动画 | `Boolean` | `false` | - | | is-deleting | 是否显示删除按钮加载动画 | `Boolean` | `false` | - | +| tel-validator | 手机号格式校验函数 | `(tel: string) => boolean` | - | - | ### Event diff --git a/docs/markdown/zh-CN/contact.md b/docs/markdown/zh-CN/contact.md index c839f1fc8..1daf259d8 100644 --- a/docs/markdown/zh-CN/contact.md +++ b/docs/markdown/zh-CN/contact.md @@ -162,6 +162,7 @@ export default { | is-edit | 是否为编辑联系人 | `Boolean` | `false` | - | | is-saving | 是否显示保存按钮加载动画 | `Boolean` | `false` | - | | is-deleting | 是否显示删除按钮加载动画 | `Boolean` | `false` | - | +| tel-validator | 手机号格式校验函数 | `(tel: string) => boolean` | - | - | ### ContactEdit Event diff --git a/packages/address-edit/index.vue b/packages/address-edit/index.vue index 236fbc133..56d9de8a2 100644 --- a/packages/address-edit/index.vue +++ b/packages/address-edit/index.vue @@ -126,6 +126,10 @@ export default create({ searchResult: { type: Array, default: () => [] + }, + telValidator: { + type: Function, + default: validateMobile } }, @@ -233,7 +237,7 @@ export default create({ case 'name': return value ? value.length <= 15 ? '' : $t('nameOverlimit') : $t('nameEmpty'); case 'tel': - return validateMobile(value) ? '' : $t('telWrong'); + return this.telValidator(value) ? '' : $t('telWrong'); case 'area_code': return value ? +value !== -1 ? '' : $t('areaWrong') : $t('areaEmpty'); case 'address_detail': diff --git a/packages/contact-edit/index.vue b/packages/contact-edit/index.vue index 123f8ffb3..8283f9cc7 100644 --- a/packages/contact-edit/index.vue +++ b/packages/contact-edit/index.vue @@ -54,6 +54,10 @@ export default create({ tel: '', name: '' }) + }, + telValidator: { + type: Function, + default: validateMobile } }, @@ -84,7 +88,7 @@ export default create({ case 'name': return value ? value.length <= 15 ? '' : this.$t('nameOverlimit') : this.$t('nameEmpty'); case 'tel': - return validateMobile(value) ? '' : this.$t('telInvalid'); + return this.telValidator(value) ? '' : this.$t('telInvalid'); } },