mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[new feature] Stepper: add show-plus & show-minus prop (#4056)
This commit is contained in:
parent
40423d1f28
commit
19c2fab0d6
@ -9,7 +9,7 @@
|
|||||||
- 修复 Popup 设置 z-index 顺序错误的问题 [\#4026](https://github.com/youzan/vant/pull/4026)
|
- 修复 Popup 设置 z-index 顺序错误的问题 [\#4026](https://github.com/youzan/vant/pull/4026)
|
||||||
|
|
||||||
|
|
||||||
### [v2.1.0](https://github.com/youzan/vant/tree/v2.1.0) [已废弃]
|
### [v2.1.0](https://github.com/youzan/vant/tree/v2.1.0)
|
||||||
`2019-08-01` 🇨🇳
|
`2019-08-01` 🇨🇳
|
||||||
|
|
||||||
**Improvements**
|
**Improvements**
|
||||||
|
@ -107,6 +107,8 @@ export default {
|
|||||||
| async-change | Whether to enable async change | `boolean` | `false` | - |
|
| async-change | Whether to enable async change | `boolean` | `false` | - |
|
||||||
| input-width | Input width | `string | number` | `32px` |
|
| input-width | Input width | `string | number` | `32px` |
|
||||||
| button-size | Button size | `string | number` | `28px` |
|
| button-size | Button size | `string | number` | `28px` |
|
||||||
|
| show-plus | Whether to show plus button | `boolean` | `true` |
|
||||||
|
| show-minus | Whether to show minus button | `boolean` | `true` |
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
|
@ -111,6 +111,8 @@ export default {
|
|||||||
| async-change | 是否开启异步变更,开启后需要手动控制输入值 | `boolean` | `false` | - |
|
| async-change | 是否开启异步变更,开启后需要手动控制输入值 | `boolean` | `false` | - |
|
||||||
| input-width | 输入框宽度,默认单位为`px` | `string | number` | `32px` | 1.6.13 |
|
| input-width | 输入框宽度,默认单位为`px` | `string | number` | `32px` | 1.6.13 |
|
||||||
| button-size | 按钮大小,默认单位为`px`,输入框高度会和按钮大小保持一致 | `string | number` | `28px` | 2.0.5 |
|
| button-size | 按钮大小,默认单位为`px`,输入框高度会和按钮大小保持一致 | `string | number` | `28px` | 2.0.5 |
|
||||||
|
| show-plus | 是否显示增加按钮 | `boolean` | `true` | 2.1.2 |
|
||||||
|
| show-minus | 是否显示减少按钮 | `boolean` | `true` | 2.1.2 |
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
|
@ -30,6 +30,14 @@ export default createComponent({
|
|||||||
defaultValue: {
|
defaultValue: {
|
||||||
type: [Number, String],
|
type: [Number, String],
|
||||||
default: 1
|
default: 1
|
||||||
|
},
|
||||||
|
showPlus: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
showMinus: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -204,6 +212,7 @@ export default createComponent({
|
|||||||
return (
|
return (
|
||||||
<div class={bem()}>
|
<div class={bem()}>
|
||||||
<button
|
<button
|
||||||
|
vShow={this.showMinus}
|
||||||
style={this.buttonStyle}
|
style={this.buttonStyle}
|
||||||
class={bem('minus', { disabled: this.minusDisabled })}
|
class={bem('minus', { disabled: this.minusDisabled })}
|
||||||
{...createListeners('minus')}
|
{...createListeners('minus')}
|
||||||
@ -223,6 +232,7 @@ export default createComponent({
|
|||||||
onBlur={this.onBlur}
|
onBlur={this.onBlur}
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
|
vShow={this.showPlus}
|
||||||
style={this.buttonStyle}
|
style={this.buttonStyle}
|
||||||
class={bem('plus', { disabled: this.plusDisabled })}
|
class={bem('plus', { disabled: this.plusDisabled })}
|
||||||
{...createListeners('plus')}
|
{...createListeners('plus')}
|
||||||
|
@ -5,3 +5,5 @@ exports[`disable stepper input 1`] = `<div class="van-stepper"><button class="va
|
|||||||
exports[`disabled stepper 1`] = `<div class="van-stepper"><button class="van-stepper__minus van-stepper__minus--disabled"></button><input type="number" role="spinbutton" aria-valuemax="Infinity" aria-valuemin="1" aria-valuenow="1" disabled="disabled" class="van-stepper__input"><button class="van-stepper__plus van-stepper__plus--disabled"></button></div>`;
|
exports[`disabled stepper 1`] = `<div class="van-stepper"><button class="van-stepper__minus van-stepper__minus--disabled"></button><input type="number" role="spinbutton" aria-valuemax="Infinity" aria-valuemin="1" aria-valuenow="1" disabled="disabled" class="van-stepper__input"><button class="van-stepper__plus van-stepper__plus--disabled"></button></div>`;
|
||||||
|
|
||||||
exports[`input width 1`] = `<div class="van-stepper"><button class="van-stepper__minus van-stepper__minus--disabled"></button><input type="number" role="spinbutton" aria-valuemax="Infinity" aria-valuemin="1" aria-valuenow="1" class="van-stepper__input" style="width: 10rem;"><button class="van-stepper__plus"></button></div>`;
|
exports[`input width 1`] = `<div class="van-stepper"><button class="van-stepper__minus van-stepper__minus--disabled"></button><input type="number" role="spinbutton" aria-valuemax="Infinity" aria-valuemin="1" aria-valuenow="1" class="van-stepper__input" style="width: 10rem;"><button class="van-stepper__plus"></button></div>`;
|
||||||
|
|
||||||
|
exports[`show-plus & show-minus props 1`] = `<div class="van-stepper"><button class="van-stepper__minus van-stepper__minus--disabled" style="display: none;"></button><input type="number" role="spinbutton" aria-valuemax="Infinity" aria-valuemin="1" aria-valuenow="1" class="van-stepper__input"><button class="van-stepper__plus" style="display: none;"></button></div>`;
|
||||||
|
@ -176,3 +176,14 @@ test('min value is 0', () => {
|
|||||||
|
|
||||||
expect(wrapper.emitted('input')[0][0]).toEqual(0);
|
expect(wrapper.emitted('input')[0][0]).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('show-plus & show-minus props', () => {
|
||||||
|
const wrapper = mount(Stepper, {
|
||||||
|
propsData: {
|
||||||
|
showPlus: false,
|
||||||
|
showMinus: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user