vuejs / router

🚦 The official router for Vue.js
https://router.vuejs.org/
MIT License
3.91k stars 1.19k forks source link

docs: mention useRouter for programmatic navigation #2070

Closed skirtles-code closed 10 months ago

skirtles-code commented 10 months ago

This note has been carried across from the v3 docs, but it has a couple of problems in the context of Vue Router 4.

It uses the term 'Vue instance', which is Vue 2 terminology. That term is no longer used in the core Vue 3 docs and it's likely that the reader won't have encountered it before.

The mention of this.$router is fine, but I think it'll derail newcomers who are using the Composition API. useRouter() is briefly mentioned a couple of pages earlier, but I doubt most readers would have that fresh in their mind when they reach this page.

I think having the note makes sense. This page (Programmatic Navigation) is one of the few pages where the router is accessed in components. I've reworded it to try to make it a better reflection of using Vue Router with Vue 3. Arguably it still places too much emphasis on the Options API, but I think that keeps it consistent with the rest of the router docs.

netlify[bot] commented 10 months ago

Deploy Preview for vue-router ready!

Name Link
Latest commit 100b65d4377bcd3fdd9a35a3d3affd057f7b3f9a
Latest deploy log https://app.netlify.com/sites/vue-router/deploys/6570a4d3f08168000980cbbe
Deploy Preview https://deploy-preview-2070--vue-router.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.