[Vuejs]-Modifying Vue query with beforeEnter

0πŸ‘

βœ…

It’s not great, but I modified hackSearch() so it would return whether or not it had found an offending term and replaced it. This enables the code above to be modified as follows:

{
    name: "search",
    path: "/search",
    component: Records,
    beforeEnter(to, from, next) {
        let [query, modified] = hackSearch(to.query);
        if (modified) {
            next({name: 'search', query: query});
        }
        else {
            next();
        }
    }

},

Leave a comment