Router.navigate with reloadAll causes exception

I have set a redirect to the DashboardPage within the page:beforein callback, for preventing the logged user to see the LandingPage. I do this by doing

    this.$f7.views.main.router.navigate('/dashboard/', {reloadAll : true});

I use reloadAll because I want to clean the DOM stack and the history. But when navigating back to the LandingPage, the beforein callback generates an exception

Uncaught TypeError: Cannot read property 'f7Page' of undefined
    at Router.removePage (webpack:///./node_modules/framework7-vue/utils/components-router.js?:59)
    at afterAnimation (webpack:///./node_modules/framework7/modules/router/navigate.js?:550)
    at eval (webpack:///./node_modules/framework7/modules/router/navigate.js?:595)
    at onDone (webpack:///./node_modules/framework7/modules/router/router-class.js?:314)
    at HTMLDivElement.eval (webpack:///./node_modules/framework7/modules/router/router-class.js?:318)
    at HTMLDivElement.fireCallBack (webpack:///./node_modules/dom7/dist/dom7.module.js?:609)
    at HTMLDivElement.handleEvent (webpack:///./node_modules/dom7/dist/dom7.module.js?:407)

The div.view-main element still has the router-transition-backward and router-transition classes so the entire view is white. What is my mistake?

Maybe this is because the first call to .navigate(“Dashboard”) has already cleaned the history, and if I clean it twice, I get the error…

It is not allowed to call router methods while current routing is in progress. Use route’s beforeEnter for this case

1 Like

beforeEnter не позволяет же изменить роут? Автору нужен async в любом случае

Автор по сути делает редирект, это можно сделать через beforeEnter

Можно пример? С учетом того, чтобы не менять вручную как вы и написали “It is not allowed to call router methods while current routing is in progress.”

beforeEnter(to, from, resolve, reject) {
  const router = this;
  if (somethingIsWrong) {
  } else {
1 Like

It seems that the beforeEnter callback is not called

  1. when navigating back in the page stack/history after it has been created, and
  2. at app startup.

Am I wrong?

I am wrong, yes. beforeEnter is called in such situations

Yes, it is called everytime new route is going to be entered - forward and backward