I have a landing page '/'
that users will see first when they visit our website. I want to display a loading wheel for 5 seconds before automatically redirecting them to the login page '/login'
.
My Landing.vue page in Vue and Bulma.io looks like this:
<template>
<div class="image">
<img src="../assets/landing.png">
<div class="loader loading"></div>
</div>
</template>
<!-- Styles -->
<style>
.loading {
border: 2px solid #dbdbdb;
border-radius: 290486px;
border-right-color: transparent;
border-top-color: transparent;
content: "";
display: block;
height: 1em;
position: absolute;
width: 1em;
transform: translate(-50%,-50%);
margin-right: -50%;
top: 30%;
left: 50%;
}
</style>
<!-- Scripts -->
<script>
setTimeout( function() { this.$router.push({ path: '/login'})},5000);
</script>
In my router/index.js file, here's what I have:
/*
Necessary imports...notice I imported the two components we will use (Login and Home)
*/
import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/components/Login'
import Home from '@/components/Home'
import Landing from '@/components/Landing'
// Needed to make use of the vue-router system
Vue.use(Router)
export default new Router({
// Define the routes...will add more when needed
routes: [
{
path: '/home', // URL path
name: 'Home',
component: Home // created component
},
{
path: '/login', // URL path
name: 'Login',
component: Login // created component
},
{
path: '/', // URL path
name: 'Landing',
component: Landing // created component
}
]
})
Is there something wrong with the script section causing issues? Any help is appreciated.