Categories
Vue Answers

How to go back with Vue Router?

Spread the love

Sometimes, we want to go back with Vue Router.

In this article, we’ll look at how to go back with Vue Router.

How to go back with Vue Router?

To go back with Vue Router, we can use the $router.go method.

For instance, we write

<template>
  <a @click="$router.go(-1)">back</a>
</template>

to add a link that calls $router.go with -1 to go back to the previous route when we click it.

Conclusion

To go back with Vue Router, we can use the $router.go method.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *