The vue-router is currently working well, but we are interested in pushing a route from another file. Here is an example of the code:
// src/router/index.ts
import { route } from 'quasar/wrappers'
import VueRouter from 'vue-router'
import routes from './routes'
export default route(function ({ Vue }) {
Vue.use(VueRouter)
const Router = new VueRouter({
scrollBehavior: () => ({ x: 0, y: 0 }),
routes,
mode: process.env.VUE_ROUTER_MODE,
base: process.env.VUE_ROUTER_BASE,
})
return Router
})
We would like to be able to modify the route from another file as shown below:
// src/services/auth/authService.ts
import router from 'src/router'
if (router.currentRoute.path === '/login') {
console.log('authService push to /');
router.push('/')
}
However, when attempting this, we encounter the following error:
TS2339: Property 'currentRoute' does not exist on type 'RouteCallback'.
It seems that there might be an issue with how we are exporting/importing the router.