feat(Calendar): add close、closed event

This commit is contained in:
陈嘉涵 2020-02-20 19:39:34 +08:00
parent e0c332a41f
commit 556f335cc2
4 changed files with 19 additions and 0 deletions

View File

@ -251,6 +251,8 @@ Set `poppable` to `false`, the calendar will be displayed directly on the page i
|------|------|------|
| select | Triggered when select date | *value: Date \| Date[]* |
| confirm | Triggered after date selection is completeif `show-confirm` is` true`, it is triggered after clicking the confirm button | *value: Date \| Date[]* |
| close `v2.5.2` | Triggered when close Calendar Popup | - |
| closed `v2.5.2` | Triggered when closed Calendar Popup | - |
### Slots

View File

@ -253,6 +253,8 @@ export default {
|------|------|------|
| select | 点击任意日期时触发 | *value: Date \| Date[]* |
| confirm | 日期选择完成后触发,若`show-confirm``true`,则点击确认按钮后触发 | *value: Date \| Date[]* |
| close `v2.5.2` | 关闭弹出层时触发 | - |
| closed `v2.5.2` | 关闭弹出层且动画结束后触发 | - |
### Slots

View File

@ -373,6 +373,8 @@ export default createComponent({
render() {
if (this.poppable) {
const createListener = name => () => this.$emit(name);
return (
<Popup
round
@ -385,6 +387,8 @@ export default createComponent({
closeOnPopstate={this.closeOnPopstate}
closeOnClickOverlay={this.closeOnClickOverlay}
onInput={this.togglePopup}
onClose={createListener('close')}
onClosed={createListener('closed')}
>
{this.genCalendar()}
</Popup>

View File

@ -450,3 +450,14 @@ test('max-range prop', async () => {
expect(wrapper.emitted('confirm')).toBeFalsy();
});
test('close event', () => {
const wrapper = mount(Calendar, {
propsData: {
value: true,
},
});
wrapper.setProps({ value: false });
expect(wrapper.emitted('close')).toBeTruthy();
});