mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-23 09:52:57 +08:00
fix(Slider): should format initial value (#4337)
This commit is contained in:
parent
390e89fca2
commit
45d60aaf88
@ -62,7 +62,7 @@ export default {
|
|||||||
|------|------|------|------|------|
|
|------|------|------|------|------|
|
||||||
| title | Content | *string* | `''` | - |
|
| title | Content | *string* | `''` | - |
|
||||||
| info | Info Message | *string \| number* | `''` | - |
|
| 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* | - | - |
|
| url | Link | *string* | - | - |
|
||||||
| to | Target route of the link, same as to of vue-router | *string \| object* | - | 2.0.4 |
|
| 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 |
|
| replace | If true, the navigation will not leave a history record | *boolean* | `false` | 2.0.4 |
|
||||||
|
@ -66,7 +66,7 @@ export default {
|
|||||||
|------|------|------|------|------|
|
|------|------|------|------|------|
|
||||||
| title | 内容 | *string* | `''` | - |
|
| title | 内容 | *string* | `''` | - |
|
||||||
| info | 提示消息 | *string \| number* | `''` | - |
|
| info | 提示消息 | *string \| number* | `''` | - |
|
||||||
| disabled | 是否禁用该项 | *boolean* | `false` | 2.1.9 |
|
| disabled | 是否禁用该项 | *boolean* | `false` | 2.2.0 |
|
||||||
| url | 跳转链接 | *string* | - | - |
|
| url | 跳转链接 | *string* | - | - |
|
||||||
| to | 路由跳转对象,同 vue-router 的 to 属性 | *string \| object* | - | 2.0.4 |
|
| to | 路由跳转对象,同 vue-router 的 to 属性 | *string \| object* | - | 2.0.4 |
|
||||||
| replace | 跳转时是否替换当前页面历史 | *boolean* | `false` | 2.0.4 |
|
| replace | 跳转时是否替换当前页面历史 | *boolean* | `false` | 2.0.4 |
|
||||||
|
@ -40,6 +40,11 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
created() {
|
||||||
|
// format initial value
|
||||||
|
this.updateValue(this.value);
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onTouchStart(event) {
|
onTouchStart(event) {
|
||||||
if (this.disabled) {
|
if (this.disabled) {
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
import Slider from '..';
|
import Slider from '..';
|
||||||
import { mount, trigger, triggerDrag, mockGetBoundingClientRect } from '../../../test/utils';
|
import {
|
||||||
|
mount,
|
||||||
|
trigger,
|
||||||
|
triggerDrag,
|
||||||
|
mockGetBoundingClientRect
|
||||||
|
} from '../../../test/utils';
|
||||||
|
|
||||||
function mockRect(vertical) {
|
function mockRect(vertical) {
|
||||||
return mockGetBoundingClientRect({
|
return mockGetBoundingClientRect({
|
||||||
@ -134,3 +139,17 @@ it('should not emit change event when value not changed', () => {
|
|||||||
|
|
||||||
expect(wrapper.emitted('change').length).toEqual(1);
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@ -97,7 +97,7 @@ export default {
|
|||||||
| height | Height | *string \| number* | `300` | - |
|
| height | Height | *string \| number* | `300` | - |
|
||||||
| main-Active-index | The index of selected parent node | *number* | `0` | - |
|
| main-Active-index | The index of selected parent node | *number* | `0` | - |
|
||||||
| active-id | Id of selected item | *string \| number \| (string \| 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
|
### Events
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ export default {
|
|||||||
| height | 高度,默认单位为 px | *string \| number* | `300` | - |
|
| height | 高度,默认单位为 px | *string \| number* | `300` | - |
|
||||||
| main-active-index | 左侧选中项的索引 | *number* | `0` | - |
|
| main-active-index | 左侧选中项的索引 | *number* | `0` | - |
|
||||||
| active-id | 右侧选中项的 id,支持传入数组 | *string \| number \| (string \| number)[]* | `0` | - |
|
| active-id | 右侧选中项的 id,支持传入数组 | *string \| number \| (string \| number)[]* | `0` | - |
|
||||||
| max | 右侧项最大选中个数 | *number* | *Infinity* | 2.1.9 |
|
| max | 右侧项最大选中个数 | *number* | *Infinity* | 2.2.0 |
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user