mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-22 22:49:15 +08:00
[new feature] Stepper: add focus event (#2841)
This commit is contained in:
parent
2b9c30f906
commit
8f3dc3f9ca
@ -93,4 +93,5 @@ export default {
|
|||||||
| overlimit | Triggered when click disabled button | - |
|
| overlimit | Triggered when click disabled button | - |
|
||||||
| plus | Triggered when click plus button | - |
|
| plus | Triggered when click plus button | - |
|
||||||
| minus | Triggered when click minus button | - |
|
| minus | Triggered when click minus button | - |
|
||||||
|
| focus | Triggered when input focused | - |
|
||||||
| blur | Triggered when input blured | - |
|
| blur | Triggered when input blured | - |
|
||||||
|
@ -107,6 +107,10 @@ export default sfc({
|
|||||||
this.$emit(type);
|
this.$emit(type);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onFocus(event) {
|
||||||
|
this.$emit('focus', event);
|
||||||
|
},
|
||||||
|
|
||||||
onBlur(event) {
|
onBlur(event) {
|
||||||
this.currentValue = this.range(this.currentValue);
|
this.currentValue = this.range(this.currentValue);
|
||||||
this.$emit('blur', event);
|
this.$emit('blur', event);
|
||||||
@ -135,6 +139,7 @@ export default sfc({
|
|||||||
value={this.currentValue}
|
value={this.currentValue}
|
||||||
disabled={this.disabled || this.disableInput}
|
disabled={this.disabled || this.disableInput}
|
||||||
onInput={this.onInput}
|
onInput={this.onInput}
|
||||||
|
onFocus={this.onFocus}
|
||||||
onBlur={this.onBlur}
|
onBlur={this.onBlur}
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
|
@ -80,6 +80,13 @@ test('only allow interger', () => {
|
|||||||
expect(wrapper.emitted('input')).toEqual([[1]]);
|
expect(wrapper.emitted('input')).toEqual([[1]]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('stepper focus', () => {
|
||||||
|
const wrapper = mount(Stepper);
|
||||||
|
const input = wrapper.find('input');
|
||||||
|
input.trigger('focus');
|
||||||
|
expect(wrapper.emitted('focus')).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
test('stepper blur', () => {
|
test('stepper blur', () => {
|
||||||
const wrapper = mount(Stepper, {
|
const wrapper = mount(Stepper, {
|
||||||
propsData: {
|
propsData: {
|
||||||
|
@ -96,4 +96,5 @@ export default {
|
|||||||
| overlimit | 点击不可用的按钮时触发 | - |
|
| overlimit | 点击不可用的按钮时触发 | - |
|
||||||
| plus | 点击增加按钮时触发 | - |
|
| plus | 点击增加按钮时触发 | - |
|
||||||
| minus | 点击减少按钮时触发 | - |
|
| minus | 点击减少按钮时触发 | - |
|
||||||
|
| focus | 输入框聚焦时触发 | - |
|
||||||
| blur | 输入框失焦时触发 | - |
|
| blur | 输入框失焦时触发 | - |
|
||||||
|
Loading…
x
Reference in New Issue
Block a user