diff --git a/src/calendar/README.md b/src/calendar/README.md index 0b0abd264..3df673156 100644 --- a/src/calendar/README.md +++ b/src/calendar/README.md @@ -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 diff --git a/src/calendar/README.zh-CN.md b/src/calendar/README.zh-CN.md index 6ae7c08e2..6b7e6c2f9 100644 --- a/src/calendar/README.zh-CN.md +++ b/src/calendar/README.zh-CN.md @@ -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 diff --git a/src/calendar/index.js b/src/calendar/index.js index 24311e7b3..67d601fc9 100644 --- a/src/calendar/index.js +++ b/src/calendar/index.js @@ -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]; } diff --git a/src/calendar/test/prop.spec.js b/src/calendar/test/prop.spec.js index 304c56153..6d8ec8ec7 100644 --- a/src/calendar/test/prop.spec.js +++ b/src/calendar/test/prop.spec.js @@ -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(); +});