[Vuejs]-How to access Vue's methods from navigation guard?

0👍

By inspecting the router, finally found a workaround.

The router has a apps property, which turns out that the router.apps[1] contains the methods!

So the change is:

router.beforeEach(async function (to, from, next) {
-  router.app.aMethod();
+  router.apps[1].aMethod();
});

Leave a comment