feat(Calendar): add month-show event (#6292)

This commit is contained in:
neverland 2020-05-17 20:28:53 +08:00 committed by GitHub
parent 6870bdcbc2
commit f2ec0c5a4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 1 deletions

View File

@ -291,6 +291,7 @@ Following props are supported when the type is multiple
| opened `v2.5.2` | Triggered when opened Popup | - |
| closed `v2.5.2` | Triggered when closed Popup | - |
| unselect `v2.7.2` | Triggered when unselect date when type is multiple | _value: Date_ |
| month-show `v2.8.2` | Triggered when a month enters the visible area | _{ date: Date, title: string }_ |
### Slots

View File

@ -294,7 +294,8 @@ export default {
| close `v2.5.2` | 关闭弹出层时触发 | - |
| opened `v2.5.2` | 打开弹出层且动画结束后触发 | - |
| closed `v2.5.2` | 关闭弹出层且动画结束后触发 | - |
| unselect `v2.7.2` | 当 Canlendar 的 `type``multiple` 时,取消选中日期时触发 | _value: Date_ |
| unselect `v2.7.2` | 当日历组件的 `type``multiple` 时,取消选中日期时触发 | _value: Date_ |
| month-show `v2.8.2` | 当某个月份进入可视区域时触发 | _{ date: Date, title: string }_ |
### Slots

View File

@ -253,6 +253,13 @@ export default createComponent({
currentMonth = months[i];
}
if (!months[i].visible && visible) {
this.$emit('month-show', {
date: months[i].date,
title: months[i].title,
});
}
months[i].visible = visible;
height += heights[i];
}

View File

@ -180,3 +180,14 @@ test('lazy-render prop', () => {
expect(wrapper).toMatchSnapshot();
});
test.only('month-show event', async () => {
const wrapper = mount(Calendar, {
propsData: {
value: true,
},
});
await later();
expect(wrapper.emitted('month-show')).toBeTruthy();
});