Vue.JS Automatically Page Redirection

Today, We want to share with you Vue.JS Automatically Page Redirection.In this post we will show you vue router conditional redirect, hear for vue router redirect to external url we will give you demo and example for implement.In this post, we will learn about How to redirect from one page to another page in Vue Router with an example.

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

Vue.JS Automatically Page Redirection

There are the Following The simple About Vue.JS Automatically Page Redirection Full Information With Example and source code.

As I will cover this Post with live Working example to develop vue router redirect with params, so the vue router redirect to child for this example is following below.

VueJS: Automatically Redirect on Page Load

function checkSignIn(){
     //do something, fetch signin status from server whatsoever

     return status; //boolean
}

function redirect(){
    const url = window.location.search.split("?link=")[1];
    const externalurl = 'https://www.pakainfo.com';
    //fetch url, parse, etc etc

    //check signin status
    if(checkSignIn()){
         window.location.href = externalurl;
    }
    else {
         window.location.href = 'signin.html';
    }
}

window.onload = function(){
    redirect();
}

Using Vuejs

<template>
<div>
  <p>Good Luck, Redirecting...</p>
</div>
</template>

<script>
export default {
  mounted () {
    const member = this.$store.state.auth.member
    if (member !== null) {
      if (this.$route.query.link) {
        window.location.href = this.$route.query.link
      } else {
        window.location.href = '' // Some here put yourr default link
      }
    } else {
      window.location.href = '' // signIn page
    }
  }
}
</script>

Vue.js redirection to another page

this.$router.push('/your-url-path')

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Vue.JS Automatically Page Redirection.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.


Related FAQ

Here are some more FAQ related to this Article:

  1.   Laravel Bootstrap Toggle switch Update DB field using Ajax
  2.   Send Email via SMTP Server in Node.js using Nodemailer npm
  3.   WordPress Plugin Activation Dependency Check
  4.   Nested Child Routes in Vuejs Navigate Menu
  5.   Vue JS - Get Query String Value Example
  6.   VueJS Routing and Templating example
  7.   Remove specific value from php array
  8.   Elementor custom taxonomy select
  9.   How to Make Links Open in a New Window or Tab using Vue JS?
  10.   Simple Vue Router Example From Scratch

Leave a Reply

Your email address will not be published. Required fields are marked *