fix(Slider): should format initial value (#4337)

This commit is contained in:
neverland 2019-09-03 11:57:48 +08:00 committed by GitHub
parent 390e89fca2
commit 45d60aaf88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 5 deletions

View File

@ -62,7 +62,7 @@ export default {
|------|------|------|------|------|
| title | Content | *string* | `''` | - |
| info | Info Message | *string \| number* | `''` | - |
| disabled | Whether to be disabled | *boolean* | `false` | 2.1.9 |
| disabled | Whether to be disabled | *boolean* | `false` | 2.2.0 |
| url | Link | *string* | - | - |
| to | Target route of the link, same as to of vue-router | *string \| object* | - | 2.0.4 |
| replace | If true, the navigation will not leave a history record | *boolean* | `false` | 2.0.4 |

View File

@ -66,7 +66,7 @@ export default {
|------|------|------|------|------|
| title | 内容 | *string* | `''` | - |
| info | 提示消息 | *string \| number* | `''` | - |
| disabled | 是否禁用该项 | *boolean* | `false` | 2.1.9 |
| disabled | 是否禁用该项 | *boolean* | `false` | 2.2.0 |
| url | 跳转链接 | *string* | - | - |
| to | 路由跳转对象,同 vue-router 的 to 属性 | *string \| object* | - | 2.0.4 |
| replace | 跳转时是否替换当前页面历史 | *boolean* | `false` | 2.0.4 |

View File

@ -40,6 +40,11 @@ export default createComponent({
}
},
created() {
// format initial value
this.updateValue(this.value);
},
methods: {
onTouchStart(event) {
if (this.disabled) {

View File

@ -1,5 +1,10 @@
import Slider from '..';
import { mount, trigger, triggerDrag, mockGetBoundingClientRect } from '../../../test/utils';
import {
mount,
trigger,
triggerDrag,
mockGetBoundingClientRect
} from '../../../test/utils';
function mockRect(vertical) {
return mockGetBoundingClientRect({
@ -134,3 +139,17 @@ it('should not emit change event when value not changed', () => {
expect(wrapper.emitted('change').length).toEqual(1);
});
it('should format initial value', done => {
mount(Slider, {
propsData: {
value: null
},
listeners: {
input(value) {
expect(value).toEqual(0);
done();
}
}
});
});

View File

@ -97,7 +97,7 @@ export default {
| height | Height | *string \| number* | `300` | - |
| main-Active-index | The index of selected parent node | *number* | `0` | - |
| active-id | Id of selected item | *string \| number \| (string \| number)[]* | `0` | - |
| max | Maximum number of selected items | *number* | `Infinity` | 2.1.9 |
| max | Maximum number of selected items | *number* | `Infinity` | 2.2.0 |
### Events

View File

@ -103,7 +103,7 @@ export default {
| height | 高度,默认单位为 px | *string \| number* | `300` | - |
| main-active-index | 左侧选中项的索引 | *number* | `0` | - |
| active-id | 右侧选中项的 id支持传入数组 | *string \| number \| (string \| number)[]* | `0` | - |
| max | 右侧项最大选中个数 | *number* | *Infinity* | 2.1.9 |
| max | 右侧项最大选中个数 | *number* | *Infinity* | 2.2.0 |
### Events