mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(Stepper): add disable-plus & disable-minus props (#5180)
This commit is contained in:
parent
68164da604
commit
b042082322
@ -114,6 +114,8 @@ export default {
|
|||||||
| show-plus | Whether to show plus button | *boolean* | `true` | 2.1.2 |
|
| show-plus | Whether to show plus button | *boolean* | `true` | 2.1.2 |
|
||||||
| show-minus | Whether to show minus button | *boolean* | `true` | 2.1.2 |
|
| show-minus | Whether to show minus button | *boolean* | `true` | 2.1.2 |
|
||||||
| decimal-length | Decimal length | *number* | - | 2.2.1 |
|
| decimal-length | Decimal length | *number* | - | 2.2.1 |
|
||||||
|
| disable-plus | Whether to disable plus button | *boolean* | - | 2.3.0 |
|
||||||
|
| disable-minus | Whether to disable minus button | *boolean* | - | 2.3.0 |
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
|
@ -136,6 +136,8 @@ export default {
|
|||||||
| show-plus | 是否显示增加按钮 | *boolean* | `true` | 2.1.2 |
|
| show-plus | 是否显示增加按钮 | *boolean* | `true` | 2.1.2 |
|
||||||
| show-minus | 是否显示减少按钮 | *boolean* | `true` | 2.1.2 |
|
| show-minus | 是否显示减少按钮 | *boolean* | `true` | 2.1.2 |
|
||||||
| decimal-length | 固定显示的小数位数 | *number* | - | 2.2.1 |
|
| decimal-length | 固定显示的小数位数 | *number* | - | 2.2.1 |
|
||||||
|
| disable-plus | 是否禁用增加按钮 | *boolean* | - | 2.3.0 |
|
||||||
|
| disable-minus | 是否禁用减少按钮 | *boolean* | - | 2.3.0 |
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
|
@ -54,6 +54,12 @@ export default createComponent({
|
|||||||
showMinus: {
|
showMinus: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true
|
default: true
|
||||||
|
},
|
||||||
|
disablePlus: {
|
||||||
|
type: Boolean
|
||||||
|
},
|
||||||
|
disableMinus: {
|
||||||
|
type: Boolean
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -72,11 +78,11 @@ export default createComponent({
|
|||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
minusDisabled() {
|
minusDisabled() {
|
||||||
return this.disabled || this.currentValue <= this.min;
|
return this.disabled || this.disableMinus || this.currentValue <= this.min;
|
||||||
},
|
},
|
||||||
|
|
||||||
plusDisabled() {
|
plusDisabled() {
|
||||||
return this.disabled || this.currentValue >= this.max;
|
return this.disabled || this.disablePlus || this.currentValue >= this.max;
|
||||||
},
|
},
|
||||||
|
|
||||||
inputStyle() {
|
inputStyle() {
|
||||||
|
@ -19,6 +19,35 @@ test('disable stepper input', () => {
|
|||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('disable button', async () => {
|
||||||
|
const wrapper = mount(Stepper, {
|
||||||
|
propsData: {
|
||||||
|
value: 5
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const plus = wrapper.find('.van-stepper__plus');
|
||||||
|
const minus = wrapper.find('.van-stepper__minus');
|
||||||
|
|
||||||
|
minus.trigger('click');
|
||||||
|
|
||||||
|
expect(wrapper.emitted('overlimit')).toBeFalsy();
|
||||||
|
expect(wrapper.emitted('minus')).toBeTruthy();
|
||||||
|
expect(wrapper.emitted('change')[0]).toEqual([4, { name: '' }]);
|
||||||
|
|
||||||
|
wrapper.setProps({
|
||||||
|
disablePlus: true,
|
||||||
|
disableMinus: true
|
||||||
|
});
|
||||||
|
|
||||||
|
await later();
|
||||||
|
|
||||||
|
minus.trigger('click');
|
||||||
|
expect(wrapper.emitted('overlimit')[0][0]).toBe('minus');
|
||||||
|
plus.trigger('click');
|
||||||
|
expect(wrapper.emitted('overlimit')[1][0]).toBe('plus');
|
||||||
|
});
|
||||||
|
|
||||||
test('click button', () => {
|
test('click button', () => {
|
||||||
const wrapper = mount(Stepper, {
|
const wrapper = mount(Stepper, {
|
||||||
propsData: {
|
propsData: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user