When editor.md writes a markdown file, how does the generated directory change with the scroll bar?

screenshot of Tencent Cloud api document official website

vue editor.mdmarkdown


first, get the id property of the title corresponding to the left content through the navigation bar on the right, then get the corresponding offsetTop through document.querySelector (id) .offsetTop and save it, and finally use window.addEventListener ('scroll', this.handleScroll) to monitor the position of the current scroll bar and display the color to the left frame in front of the navigation bar on the right.

of course, it is important to note that because the pictures and flowcharts are generated behind time, in the second step, I used setTimeOut to delay the 200ms and then to get the offsetTop

Menu