I
I
Igor Bezlepkin2018-04-26 16:32:16
JavaScript
Igor Bezlepkin, 2018-04-26 16:32:16

How to catch a router transition in Framework7?

Hey! Is there an analogue of router.beforeEach() in Framework7 in routers?
It is necessary if the user is logged out to redirect him to the authorization form.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2018-04-26
@Sanasol

https://framework7.io/docs/view.html#router-instan...
documentation, no?

S
Sergey Levchenko, 2018-04-27
@nuykon

In main.js

mounted () {
  this.$f7.view.main.router.on('pageBeforeIn', function () {
    if (userSignIn) {
      console.log('авторизован');
    } else {
      console.log('не авторизован, редиректим на логин пэйдж');
      this.$f7.view.main.router.navigate('/login/',{reloadCurrent: true});
    }
  });
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question