feat(AddressEdit): add tel-maxlength prop (#6869)

This commit is contained in:
neverland 2020-07-25 10:36:45 +08:00 committed by GitHub
parent b7a7e48eea
commit 08a554c5a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 3 deletions

View File

@ -86,6 +86,7 @@ export default {
| is-saving | Whether to show save button loading status | _boolean_ | `false` | | is-saving | Whether to show save button loading status | _boolean_ | `false` |
| is-deleting | Whether to show delete 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_ | - | | tel-validator | The method to validate tel | _(tel: string) => boolean_ | - |
| tel-maxlength `v2.10.0` | Tel maxlength | _number \| string_ | - |
| postal-validator `v2.1.2` | The method to validate postal | _(tel: string) => boolean_ | - | | postal-validator `v2.1.2` | The method to validate postal | _(tel: string) => boolean_ | - |
| validator | Custom validator | _(key, val) => string_ | - | | validator | Custom validator | _(key, val) => string_ | - |

View File

@ -86,6 +86,7 @@ export default {
| is-saving | 是否显示保存按钮加载动画 | _boolean_ | `false` | | is-saving | 是否显示保存按钮加载动画 | _boolean_ | `false` |
| is-deleting | 是否显示删除按钮加载动画 | _boolean_ | `false` | | is-deleting | 是否显示删除按钮加载动画 | _boolean_ | `false` |
| tel-validator | 手机号格式校验函数 | _string => boolean_ | - | | tel-validator | 手机号格式校验函数 | _string => boolean_ | - |
| tel-maxlength `v2.10.0` | 手机号最大长度 | _number \| string_ | - |
| postal-validator `v2.1.2` | 邮政编码格式校验函数 | _string => boolean_ | - | | postal-validator `v2.1.2` | 邮政编码格式校验函数 | _string => boolean_ | - |
| validator | 自定义校验函数 | _(key, val) => string_ | - | | validator | 自定义校验函数 | _(key, val) => string_ | - |

View File

@ -40,11 +40,12 @@ export default createComponent({
showDelete: Boolean, showDelete: Boolean,
showPostal: Boolean, showPostal: Boolean,
searchResult: Array, searchResult: Array,
telMaxlength: [Number, String],
showSetDefault: Boolean, showSetDefault: Boolean,
showSearchResult: Boolean,
saveButtonText: String, saveButtonText: String,
deleteButtonText: String,
areaPlaceholder: String, areaPlaceholder: String,
deleteButtonText: String,
showSearchResult: Boolean,
showArea: { showArea: {
type: Boolean, type: Boolean,
default: true, default: true,
@ -283,6 +284,7 @@ export default createComponent({
clearable clearable
type="tel" type="tel"
label={t('tel')} label={t('tel')}
maxlength={this.telMaxlength}
placeholder={t('telPlaceholder')} placeholder={t('telPlaceholder')}
errorMessage={errorInfo.tel} errorMessage={errorInfo.tel}
onFocus={onFocus('tel')} onFocus={onFocus('tel')}

View File

@ -1,6 +1,6 @@
import AddressEdit from '..'; import AddressEdit from '..';
import areaList from '../../area/demo/area-simple'; import areaList from '../../area/demo/area-simple';
import { mount, later } from '../../../test'; import { mount, later, trigger } from '../../../test';
const addressInfo = { const addressInfo = {
name: '测试', name: '测试',
@ -306,3 +306,17 @@ test('click-area event', () => {
field.trigger('click'); field.trigger('click');
expect(wrapper.emitted('click-area')[0]).toBeTruthy(); expect(wrapper.emitted('click-area')[0]).toBeTruthy();
}); });
test('tel-maxlength prop', () => {
const wrapper = mount(AddressEdit, {
propsData: {
telMaxlength: 4,
},
});
const telInput = wrapper.find('input[type="tel"]');
telInput.element.value = '123456';
trigger(telInput, 'input');
expect(telInput.element.value).toEqual('1234');
});