diff --git a/src/calendar/components/Month.js b/src/calendar/components/Month.js index 9704a40ea..8a66ad73b 100644 --- a/src/calendar/components/Month.js +++ b/src/calendar/components/Month.js @@ -103,10 +103,7 @@ export default createComponent({ methods: { getHeight() { - if (!this.height) { - this.height = this.$el.getBoundingClientRect().height; - } - return this.height; + return this.$el?.getBoundingClientRect().height || 0; }, scrollIntoView(body) { diff --git a/src/calendar/index.js b/src/calendar/index.js index fa8f49bf3..11e88d677 100644 --- a/src/calendar/index.js +++ b/src/calendar/index.js @@ -108,6 +108,12 @@ export default createComponent({ }, }, + inject: { + vanPopup: { + default: null, + }, + }, + data() { return { subtitle: '', @@ -165,6 +171,8 @@ export default createComponent({ mounted() { this.init(); + // https://github.com/youzan/vant/issues/9845 + this.vanPopup?.$on('opened', this.onScroll); }, /* istanbul ignore next */