A
A
Andrey Sobolev2020-11-27 16:37:39
Vue.js
Andrey Sobolev, 2020-11-27 16:37:39

How to update component when $route get parameter update?

using vue 3
in function update get parameter and push route route

let route = {
                name  : this.$route.name,
                path  : this.$route.path,
                params: this.cloneObject(this.$route.params),
                query : this.cloneObject(this.$route.query)
            };
            route.query.q = this.search;
            this.$router.push(route);


In the component, I'm trying to catch a route change in order to re-request the API
beforeRouteEnter (to, from, next) {
        next(vm => {
            console.log(1);
        });
    },
    beforeRouteUpdate (to, from, next) {
        console.log(2);
        next();
    },
    beforeRouteLeave (to, from, next) {
        console.log(3);
        next();
    },

But none of the hooks work. So how do you catch a change by get?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Gimir, 2020-11-27
@Gimir

Here is what you need - https://router.vuejs.org/guide/essentials/dynamic-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question