Vue.js Automatic Page Redirect

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')

I hope you get an idea about Vue.JS Automatically Page Redirection.


#vue  #vuejs 

Vue.js Automatic Page Redirect
1.00 GEEK