feat(Calendar): add lazy-render prop (#6245)

This commit is contained in:
neverland
2020-05-08 20:03:23 +08:00
committed by GitHub
parent 2582d334ca
commit f344334e12
6 changed files with 79 additions and 2 deletions
+7 -2
View File
@@ -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 (
<div ref="days" role="grid" class={bem('days')}>
{this.genMark()}