vuepress / core

Vue-Powered Static Site Generator
https://vuepress.vuejs.org
MIT License
2.17k stars 922 forks source link

[Bug report] does not highlight the anchor link #1520

Closed Arhell closed 2 months ago

Arhell commented 3 months ago

Description

When I go to the document everything works 1

When you copy the link in a line and open it in a new tab, it doesn’t work https://vuepress.github.io/guide/getting-started.html#try-it-online 2

Reproduction

https://vuepress.github.io/guide/getting-started.html#try-it-online

Used Package Manager

npm

System Info

official documentation
https://vuepress.github.io/guide/getting-started.html#try-it-online
Mister-Hope commented 3 months ago

@meteorlxy cc

Mister-Hope commented 3 months ago

The issue is about <RouteLink>

When the page is rendered during ssr, no hash is on route path, the computed active state is false, so <RouteLink> won't be active in SSR result.

When a path is visited with hash, the correct <RouteLink> will be active, and the computed state will be true. No rerender will be triggered by Vue, instead an SSR mismatch warning is outputed.

I think we'd better track how the original <RouterLink> solves this problem.