From 0f0a9fe6103686d8ed02500aa620b3588ed3571d Mon Sep 17 00:00:00 2001 From: anymost Date: Mon, 15 Apr 2019 11:37:30 +0800 Subject: [PATCH] fix cannot read offset of undefined on anchor component --- src/components/anchor/anchor.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/anchor/anchor.vue b/src/components/anchor/anchor.vue index 8301307a..1e9d0437 100644 --- a/src/components/anchor/anchor.vue +++ b/src/components/anchor/anchor.vue @@ -168,7 +168,9 @@ export default { this.handleScrollTo(); this.handleSetInkTop(); this.updateTitleOffset(); - this.upperFirstTitle = this.scrollElement.scrollTop < this.titlesOffsetArr[0].offset; + if (this.titlesOffsetArr[0]) { + this.upperFirstTitle = this.scrollElement.scrollTop < this.titlesOffsetArr[0].offset; + } on(this.scrollContainer, 'scroll', this.handleScroll); on(window, 'hashchange', this.handleHashChange); });