fix: 🐛 修复slider组件step属性无效问题

 Closes: #269
This commit is contained in:
Jasper 2024-04-28 17:13:32 +08:00 committed by 不如摸鱼去
parent 9e7c8d33eb
commit 50133b9e5e
2 changed files with 5 additions and 3 deletions

View File

@ -56,14 +56,14 @@ const value = ref<number[]>([10, 30])
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 | 最低版本 |
|-----|---------------------------|-----|-------|-------|--------|
|-----|---------------------------|-----|-------|-------|-------|
| v-model | 滑块值如果为array则为双向滑块 | number / array | - | - | - |
| hide-min-max | 是否显示左右的最大最小值 | boolean | - | false | - |
| hide-label | 是否显示当前滑块值 | boolean | - | false | - |
| disabled | 是否禁用 | boolean | - | false | - |
| max | 最大值 | number | - | 100 | - |
| min | 最小值,允许负数`($LOWEST_VERSION$)` | number | - | 0 | - |
| step | 步进值 | number | - | 1 | - |
| step | 步进值 | number | - | 1 | `($LOWEST_VERSION$)` |
| active-color | 进度条激活背景颜色 | string | - | linear-gradient(315deg, rgba(81,124,240,1) 0%,rgba(118,158,245,1) 100%) | - |
| inactive-color | 进度条未激活背景颜色 | string | - | #e5e5e5 | - |

View File

@ -123,9 +123,11 @@ watch(
watch(
() => props.step,
(newValue) => {
if (newValue <= 0) {
if (newValue < 1) {
stepValue.value = 1
console.warn('[wot design] warning(wd-slider): step must be greater than 0')
} else {
stepValue.value = Math.floor(newValue)
}
},
{ immediate: true }