I'm using Nuxt and I have a problem with the $router.back()
method.
When I come from outside the application and I return ($router.back()
), I am redirected outside my application.
I would like to be redirected to the reception if I don't have a route history.
How can I do please?
<template>
<a href="#" @click="hasHistory() ? $router.back() : $router.push('/')">
<font-awesome-icon :icon="['fas', 'chevron-left']" class="fa-fw" /> Retour
</a>
</template>
<script>
export default {
methods: {
hasHistory() {
return window.history.length > 1
},
},
}
</script>