@@ -89,7 +89,7 @@ export default {
8989 },
9090 methods: {
9191 clearScroll () {
92- let {observer} = this ;
92+ let {observer} = this ;
9393 if (observer) {
9494 document .querySelectorAll (' h2[id]' ).forEach ((section ) => {
9595 observer .unobserve (section);
@@ -109,15 +109,27 @@ export default {
109109 this .observer = new IntersectionObserver ((entries ) => {
110110 entries .forEach ((entry ) => {
111111 let id = entry .target .getAttribute (' id' );
112+ let hrefContent = id;
112113 id = encodeURI (id);
113114 // intersectionRatio:目标元素出现在视窗的比例
114115 if (entry .intersectionRatio > 0 ) {
115116 if (document .querySelector (` li a[href="#${ id} "]` )) {
117+ if (hrefContent !== " 产品介绍"
118+ && hrefContent !== " leaflet"
119+ && hrefContent !== " cesium"
120+ && hrefContent !== " mapboxgl"
121+ && hrefContent !== " openlayers"
122+ && hrefContent !== " vue组件开发"
123+ ){
124+ document .querySelector (' li a[href="#' + encodeURI (' 产品介绍' )+ ' "]' ).parentElement .classList .remove (' active' );
125+ }
116126 document .querySelector (` li a[href="#${ id} "]` ).parentElement .classList .add (' active' );
117127 }
118128 } else {
119129 if (document .querySelector (` li a[href="#${ id} "]` )) {
120- document .querySelector (` li a[href="#${ id} "]` ).parentElement .classList .remove (' active' );
130+ if (hrefContent .indexOf (" 产品介绍" ) < 0 ){
131+ document .querySelector (` li a[href="#${ id} "]` ).parentElement .classList .remove (' active' );
132+ }
121133 }
122134 }
123135 });
@@ -170,7 +182,6 @@ export default {
170182 resetHtml (mode , file , first ) {
171183 this .loading = true ;
172184 var self = this ;
173-
174185 var url = this .getHtmlUrl (mode, file, first);
175186 axios .get (url)
176187 .then (response => {
@@ -207,7 +218,10 @@ export default {
207218 markdownRendered () {
208219 this .isContentFinish = true ;
209220 if (this .isTocFinish && this .isContentFinish ) {
210- this .initScroll ();
221+ // this.$nextTick(function () {
222+ // // this.initScroll();
223+ // })
224+ // this.initScroll();
211225 }
212226 this .$nextTick (() => {
213227 Prism .highlightAll ();
@@ -219,7 +233,10 @@ export default {
219233 tocRendered () {
220234 this .isTocFinish = true ;
221235 if (this .isTocFinish && this .isContentFinish ) {
222- this .initScroll ();
236+ // this.initScroll();
237+ this .$nextTick (function () {
238+ this .initScroll ();
239+ })
223240 }
224241 }
225242 }
0 commit comments