Redirecting to the wanted route

After the user is logged in, the app should redirect him to the page they initially wanted to browse:

  1. Pass the current wanted URL as a parameter to the login route:
      next({
name: 'login',
params: {
wantedRoute: to.fullPath,
},
})

Now if you click on the support tickets link and get redirected to the login page, you should see the wantedRoute parameter in the $route object on any component:

  1. In the Login component, we can change the redirection in the login method and use this parameter:
      this.$router.replace(this.$route.params.wantedRoute ||
{ name: 'home' })
The router.replace() method is very similar to the router.push() method, the difference being it replaces the current entry in the browser history with the new route instead of adding a new entry.

Now if you log in, you should be redirected to the support ticket page instead of the home page.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.134.78.106