feat(Stepper): add show-input prop (#7812)

This commit is contained in:
neverland 2020-12-24 20:23:32 +08:00 committed by GitHub
parent 1fac5c5f4f
commit 97509a90b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 0 deletions

View File

@ -129,6 +129,7 @@ export default {
| async-change | Whether to enable async change | _boolean_ | `false` | - |
| show-plus | Whether to show plus button | _boolean_ | `true` |
| show-minus | Whether to show minus button | _boolean_ | `true` |
| show-input `v2.12.1` | Whether to show input | _boolean_ | `true` |
| long-press `v2.4.3` | Whether to allow long press | _boolean_ | `true` |
| allow-empty `v2.9.1` | Whether to allow the input to be empty | _boolean_ | `false` |

View File

@ -154,6 +154,7 @@ export default {
| async-change | 是否开启异步变更,开启后需要手动控制输入值 | _boolean_ | `false` |
| show-plus | 是否显示增加按钮 | _boolean_ | `true` |
| show-minus | 是否显示减少按钮 | _boolean_ | `true` |
| show-input `v2.12.1` | 是否显示输入框 | _boolean_ | `true` |
| long-press `v2.4.3` | 是否开启长按手势 | _boolean_ | `true` |
| allow-empty `v2.9.1` | 是否允许输入的值为空 | _boolean_ | `false` |

View File

@ -65,6 +65,10 @@ export default createComponent({
type: Boolean,
default: true,
},
showInput: {
type: Boolean,
default: true,
},
longPress: {
type: Boolean,
default: true,
@ -306,6 +310,7 @@ export default createComponent({
{...createListeners('minus')}
/>
<input
vShow={this.showInput}
ref="input"
type={this.integer ? 'tel' : 'text'}
role="spinbutton"

View File

@ -277,6 +277,16 @@ test('show-plus & show-minus props', () => {
expect(wrapper).toMatchSnapshot();
});
test('should hide input when show-input prop is false', () => {
const wrapper = mount(Stepper, {
propsData: {
showInput: false,
},
});
expect(wrapper.find('input').element.style.display).toEqual('none');
});
test('decimal-length prop', () => {
const wrapper = mount(Stepper, {
propsData: {