B
B
BonBon Slick2020-09-15 08:51:59
Vue.js
BonBon Slick, 2020-09-15 08:51:59

Does Vue router.go(-1) translate to the current page?

If the user tried to navigate to a page with a middleware or other listener like

beforeRouteEnter () {
            this.$router.push({name: 'team'});
        },

        beforeMount () {
            if(this.user.team.name){
                this.$router.push({name: 'team'});
            }
        },


This will always take you to the current page, because the last one visited has middleware. How to configure or define programmatically that the user would return to the latest available page? In our case, this will be , in theory, when the user was transferred to the current page from the middleware.
@click="$router.go(-1)"


$router.go(-2)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question