Commit 5b250f6e1ce72900bf12ecdd997476ed280d8902
Committed by
GitHub
Merge pull request #5628 from anymost/2.0
Fix cannot read offset of undefined on anchor component
Showing
1 changed file
with
3 additions
and
1 deletions
Show diff stats
src/components/anchor/anchor.vue
... | ... | @@ -168,7 +168,9 @@ export default { |
168 | 168 | this.handleScrollTo(); |
169 | 169 | this.handleSetInkTop(); |
170 | 170 | this.updateTitleOffset(); |
171 | - this.upperFirstTitle = this.scrollElement.scrollTop < this.titlesOffsetArr[0].offset; | |
171 | + if (this.titlesOffsetArr[0]) { | |
172 | + this.upperFirstTitle = this.scrollElement.scrollTop < this.titlesOffsetArr[0].offset; | |
173 | + } | |
172 | 174 | on(this.scrollContainer, 'scroll', this.handleScroll); |
173 | 175 | on(window, 'hashchange', this.handleHashChange); |
174 | 176 | }); | ... | ... |