<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>
Is there a way to prevent the disappearance of the text "{{ prevRoute }}" in the button after refreshing the page when using Vue router's beforeRouteEnter function? Are there alternative methods to display text in the button for the previous page?