Merge branch 'dev' into next
This commit is contained in:
+1
-1
@@ -271,7 +271,7 @@ Field support all native events of input tag
|
||||
|
||||
### Methods
|
||||
|
||||
Use [ref](https://vuejs.org/v2/api/#ref) to get Field instance and call instance methods
|
||||
Use [ref](https://vuejs.org/v2/api/#ref) to get Field instance and call instance methods.
|
||||
|
||||
| Name | Description | Attribute | Return value |
|
||||
| ----- | ------------------- | --------- | ------------ |
|
||||
|
||||
@@ -294,7 +294,7 @@ export default {
|
||||
|
||||
### 方法
|
||||
|
||||
通过 ref 可以获取到 Field 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa)
|
||||
通过 ref 可以获取到 Field 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa)。
|
||||
|
||||
| 方法名 | 说明 | 参数 | 返回值 |
|
||||
| ------ | -------------- | ---- | ------ |
|
||||
|
||||
+8
-3
@@ -240,10 +240,15 @@ export default createComponent({
|
||||
const updateValue = (value, trigger = 'onChange') => {
|
||||
value = isDef(value) ? String(value) : '';
|
||||
|
||||
// native maxlength not work when type is number
|
||||
const { maxlength } = props;
|
||||
// native maxlength have incorrect line-break counting
|
||||
// see: https://github.com/youzan/vant/issues/5033
|
||||
const { maxlength, modelValue } = props;
|
||||
if (isDef(maxlength) && value.length > maxlength) {
|
||||
value = value.slice(0, maxlength);
|
||||
if (modelValue && modelValue.length === +maxlength) {
|
||||
value = modelValue;
|
||||
} else {
|
||||
value = value.slice(0, maxlength);
|
||||
}
|
||||
}
|
||||
|
||||
if (props.type === 'number' || props.type === 'digit') {
|
||||
|
||||
@@ -171,17 +171,25 @@ test('maxlength', async () => {
|
||||
value: 1234,
|
||||
type: 'number',
|
||||
},
|
||||
listeners: {
|
||||
input(value) {
|
||||
wrapper && wrapper.setProps({ value });
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const input = wrapper.find('input');
|
||||
expect(input.element.value).toEqual('123');
|
||||
|
||||
input.element.value = 1234;
|
||||
await later();
|
||||
input.trigger('input');
|
||||
|
||||
expect(input.element.value).toEqual('123');
|
||||
expect(wrapper.emitted('input')[0][0]).toEqual('123');
|
||||
|
||||
// see: https://github.com/youzan/vant/issues/7265
|
||||
input.element.value = 1423;
|
||||
input.trigger('input');
|
||||
expect(input.element.value).toEqual('123');
|
||||
});
|
||||
|
||||
test('clearable prop', () => {
|
||||
|
||||
Reference in New Issue
Block a user