diff --git a/src/calendar/README.md b/src/calendar/README.md index aa89a3218..0b0abd264 100644 --- a/src/calendar/README.md +++ b/src/calendar/README.md @@ -228,6 +228,7 @@ Set `poppable` to `false`, the calendar will be displayed directly on the page i | row-height | Row height | _number \| string_ | `64` | | formatter | Day formatter | _(day: Day) => Day_ | - | | poppable | Whether to show the calendar inside a popup | _boolean_ | `true` | +| lazy-render `v2.8.1` | Whether to enable lazy render | _boolean_ | `true` | | show-mark | Whether to show background month mark | _boolean_ | `true` | | show-title `v2.5.5` | Whether to show title | _boolean_ | `true` | | show-subtitle `v2.5.5` | Whether to show subtitle | _boolean_ | `true` | diff --git a/src/calendar/README.zh-CN.md b/src/calendar/README.zh-CN.md index 7d3d4086b..6ae7c08e2 100644 --- a/src/calendar/README.zh-CN.md +++ b/src/calendar/README.zh-CN.md @@ -230,6 +230,7 @@ export default { | row-height | 日期行高 | _number \| string_ | `64` | | formatter | 日期格式化函数 | _(day: Day) => Day_ | - | | poppable | 是否以弹层的形式展示日历 | _boolean_ | `true` | +| lazy-render `v2.8.1` | 是否只渲染可视区域的内容 | _boolean_ | `true` | | show-mark | 是否显示月份背景水印 | _boolean_ | `true` | | show-title `v2.5.5` | 是否展示日历标题 | _boolean_ | `true` | | show-subtitle `v2.5.5` | 是否展示日历副标题(年月) | _boolean_ | `true` | diff --git a/src/calendar/components/Month.js b/src/calendar/components/Month.js index 8c8d37952..300b7cb0a 100644 --- a/src/calendar/components/Month.js +++ b/src/calendar/components/Month.js @@ -22,6 +22,7 @@ export default createComponent({ showMark: Boolean, rowHeight: [Number, String], formatter: Function, + lazyRender: Boolean, currentDate: [Date, Array], allowSameDay: Boolean, showSubtitle: Boolean, @@ -47,8 +48,12 @@ export default createComponent({ return getMonthEndDay(this.date.getFullYear(), this.date.getMonth() + 1); }, + shouldRender() { + return this.visible || !this.lazyRender; + }, + monthStyle() { - if (!this.visible) { + if (!this.shouldRender) { const padding = Math.ceil((this.totalDay + this.offset) / 7) * this.rowHeight; @@ -226,7 +231,7 @@ export default createComponent({ }, genDays() { - if (this.visible) { + if (this.shouldRender) { return (