[Vuejs]-How to add anchor links to sections of the page?

0👍

If you’re using vue, you would likely want vue router. Check out https://router.vuejs.org/api/#router-link. The relevant section explaining is just near the top, stating:


<router-link> is preferred over hard-coded <a href="..."> for the following reasons:

  • It works the same way in both HTML5 history mode and hash mode, so if you ever decide to switch mode, or when the router falls back to hash mode in IE9, nothing needs to be changed.
  • In HTML5 history mode, router-link will intercept the click event so that the browser doesn’t try to reload the page.
  • When you are using the base option in HTML5 history mode, you don’t need to include it in to prop’s URLs.

Otherwise, if the link is outbound, ie. out of site / app, a href as per usual.

Good luck

Leave a comment