Commit 0f0a9fe6103686d8ed02500aa620b3588ed3571d

Authored by anymost
1 parent 77a67f5d

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,7 +168,9 @@ export default {
168 this.handleScrollTo(); 168 this.handleScrollTo();
169 this.handleSetInkTop(); 169 this.handleSetInkTop();
170 this.updateTitleOffset(); 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 on(this.scrollContainer, 'scroll', this.handleScroll); 174 on(this.scrollContainer, 'scroll', this.handleScroll);
173 on(window, 'hashchange', this.handleHashChange); 175 on(window, 'hashchange', this.handleHashChange);
174 }); 176 });