Question: I want to get previous page link or url in `vue-router`. Like a this. How to do it?

```
const link = this.$router.getPrevLink(); // function is not exist?
this.$router.push(link);

```

Near concept is `this.$router.go(-1)`.

```
this.$router.go(-1);

```

Answer: 
For Vue 3 with Vue Router 4, my solution was:

```
this.$router.options.history.state.back

```

The final code:

```
export default defineComponent({
  name: 'Error404',
  data () {
    return {
      lastPath: null
    }
  },
  created () {
    this.lastPath = this.$router.options.history.state.back
  },
  computed: {
    prevRoutePatch () {
      return this.lastPath ? this.lastPath : '/dashboard'
    }
  }
})

```

Regards.
This routing solution will fall back to a static url if a previous url does not exist.

```
<template>
    <div>
        <router-link :to="prevRoutePath">Previous Page</router-link>
        <router-link to="/">Home Page</router-link>
    </div>
</template>

<script>
export default {
    beforeRouteEnter(to, from, next) {
        next(vm => {
            vm.prevRoute = from;
        });
    },
    computed: {
        prevRoutePath() {return this.prevRoute ? this.prevRoute.path : '/'},
    }
}
</script>

```