diff --git a/src/pull-refresh/index.js b/src/pull-refresh/index.js index 1b22c47f5..db6a58caf 100644 --- a/src/pull-refresh/index.js +++ b/src/pull-refresh/index.js @@ -99,10 +99,15 @@ export default createComponent({ onTouchEnd() { if (!this.untouchable && this.ceiling && this.deltaY) { this.duration = this.animationDuration; + if (this.status === 'loosing') { this.setStatus(this.headHeight, true); this.$emit('input', true); - this.$emit('refresh'); + + // ensure value change can be watched + this.$nextTick(() => { + this.$emit('refresh'); + }); } else { this.setStatus(0); } diff --git a/src/pull-refresh/test/index.spec.js b/src/pull-refresh/test/index.spec.js index bcdeeb1e5..12bba11a6 100644 --- a/src/pull-refresh/test/index.spec.js +++ b/src/pull-refresh/test/index.spec.js @@ -1,7 +1,7 @@ import PullRefresh from '..'; -import { mount, trigger, triggerDrag } from '../../../test/utils'; +import { mount, later, trigger, triggerDrag } from '../../../test/utils'; -test('change head content when pulling down', () => { +test('change head content when pulling down', async () => { const wrapper = mount(PullRefresh, { propsData: { value: false @@ -32,6 +32,9 @@ test('change head content when pulling down', () => { expect(wrapper).toMatchSnapshot(); expect(wrapper.emitted('input')).toBeTruthy(); + expect(wrapper.emitted('refresh')).toBeFalsy(); + + await later(); expect(wrapper.emitted('refresh')).toBeTruthy(); // end loading