mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-05 19:41:45 +08:00
feat(Stepper): add disable-long-press feature (#2691)
* feat(Stepper): add disable-long-press feature * feat(Stepper): name the same as Vant
This commit is contained in:
parent
358beafbde
commit
33c11facff
@ -18,6 +18,10 @@
|
||||
<van-stepper value="{{ 1 }}" disabled />
|
||||
</van-cell>
|
||||
|
||||
<van-cell center title="禁用长按">
|
||||
<van-stepper value="{{ 1 }}" long-press="{{ false }}" />
|
||||
</van-cell>
|
||||
|
||||
<van-cell center title="固定小数位数">
|
||||
<van-stepper value="{{ 1 }}" step="0.2" decimal-length="{{ 1 }}" />
|
||||
</van-cell>
|
||||
|
@ -339,4 +339,4 @@
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -64,6 +64,14 @@ Page({
|
||||
<van-stepper value="{{ 1 }}" disabled />
|
||||
```
|
||||
|
||||
### 关闭长按
|
||||
|
||||
通过设置`long-press`属性决定步进器是否开启长按手势
|
||||
|
||||
```html
|
||||
<van-stepper value="{{ 1 }}" long-press="{{ false }}" />
|
||||
```
|
||||
|
||||
### 固定小数位数
|
||||
|
||||
通过设置`decimal-length`属性可以保留固定的小数位数
|
||||
@ -127,6 +135,7 @@ Page({
|
||||
| decimal-length | 固定显示的小数位数 | *number* | - | - |
|
||||
| disable-plus | 是否禁用增加按钮 | *boolean* | - | - |
|
||||
| disable-minus | 是否禁用减少按钮 | *boolean* | - | - |
|
||||
| long-press | 是否开启长按手势 | *boolean* | `true` | - |
|
||||
|
||||
### Events
|
||||
|
||||
|
@ -77,7 +77,11 @@ VantComponent({
|
||||
value: true
|
||||
},
|
||||
disablePlus: Boolean,
|
||||
disableMinus: Boolean
|
||||
disableMinus: Boolean,
|
||||
longPress: {
|
||||
type: Boolean,
|
||||
value: true
|
||||
},
|
||||
},
|
||||
|
||||
data: {
|
||||
@ -160,6 +164,9 @@ VantComponent({
|
||||
},
|
||||
|
||||
onTouchStart(event: Weapp.Event) {
|
||||
if (!this.data.longPress) {
|
||||
return;
|
||||
}
|
||||
clearTimeout(this.longPressTimer);
|
||||
|
||||
const { type } = event.currentTarget.dataset;
|
||||
@ -174,6 +181,9 @@ VantComponent({
|
||||
},
|
||||
|
||||
onTouchEnd() {
|
||||
if (!this.data.longPress) {
|
||||
return;
|
||||
}
|
||||
clearTimeout(this.longPressTimer);
|
||||
},
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user