@@ -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,28 @@ 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:目标元素出现在视窗的比例
115+
114116 if (entry .intersectionRatio > 0 ) {
115117 if (document .querySelector (` li a[href="#${ id} "]` )) {
118+ if (hrefContent !== " 产品介绍"
119+ && hrefContent !== " leaflet"
120+ && hrefContent !== " cesium"
121+ && hrefContent !== " mapboxgl"
122+ && hrefContent !== " openlayers"
123+ && hrefContent !== " vue组件开发"
124+ ){
125+ document .querySelector (' li a[href="#' + encodeURI (' 产品介绍' )+ ' "]' ).parentElement .classList .remove (' active' );
126+ }
116127 document .querySelector (` li a[href="#${ id} "]` ).parentElement .classList .add (' active' );
117128 }
118129 } else {
119130 if (document .querySelector (` li a[href="#${ id} "]` )) {
120- document .querySelector (` li a[href="#${ id} "]` ).parentElement .classList .remove (' active' );
131+ if (hrefContent .indexOf (" 产品介绍" ) < 0 ){
132+ document .querySelector (` li a[href="#${ id} "]` ).parentElement .classList .remove (' active' );
133+ }
121134 }
122135 }
123136 });
@@ -170,7 +183,6 @@ export default {
170183 resetHtml (mode , file , first ) {
171184 this .loading = true ;
172185 var self = this ;
173-
174186 var url = this .getHtmlUrl (mode, file, first);
175187 axios .get (url)
176188 .then (response => {
@@ -207,7 +219,10 @@ export default {
207219 markdownRendered () {
208220 this .isContentFinish = true ;
209221 if (this .isTocFinish && this .isContentFinish ) {
210- this .initScroll ();
222+ // this.$nextTick(function () {
223+ // // this.initScroll();
224+ // })
225+ // this.initScroll();
211226 }
212227 this .$nextTick (() => {
213228 Prism .highlightAll ();
@@ -219,7 +234,10 @@ export default {
219234 tocRendered () {
220235 this .isTocFinish = true ;
221236 if (this .isTocFinish && this .isContentFinish ) {
222- this .initScroll ();
237+ // this.initScroll();
238+ this .$nextTick (function () {
239+ this .initScroll ();
240+ })
223241 }
224242 }
225243 }
0 commit comments