<script>
export default {
name: 'TEST',
data() {
return {
prevRoute: ''
}
},
methods: {
goBack() {
return this.$router.go(-1);
},
},
beforeRouteEnter(to, from, next) {
next(vm => {
vm.prevRoute = from.name
console.log(from.name)
})
},
}
</script>
<template>
<div>
<button @click="goBack" class="back">{{ prevRoute }}</button>
</div>
</template>
Vue router beforeRouteEnter - after refreshing the page, the button text {{ prevRoute }} disappears. What other ways are there to display text in the button of the previous page?