0

I'm using vue.js 2 with routers. I want to show the user a other route URL with javascript alert message.

For example the user is on the route: /register, and i want to show you the link of /login. How can i do it?

<script>
export default {
    mounted() {            
        alert(this.$router.LINK_TO_PATH) //What comes here?
    },

}

Thanks

roev
  • 1,267
  • 2
  • 16
  • 28
  • What do you mean exactly? Having a link or getting the URL of a specific page? Read this one? https://router.vuejs.org/guide/#html – kissu May 17 '22 at 08:52
  • From the article: this.$router.push('/dashboard'). how can i show the link Instead of go to it – roev May 17 '22 at 09:00
  • Try this one `this.$router.options.routes.find(route => route.name === 'login').path` I guess? – kissu May 17 '22 at 09:05
  • `$router.options.routes` gives you all the available routes in your Vue router, then you can simply find the one you're interested in and display it as you wish. – kissu May 17 '22 at 09:06
  • 4
    this might help https://stackoverflow.com/questions/42927637/get-route-by-name-and-params-for-vue-router – Pete May 17 '22 at 09:35

0 Answers0