반응형
이거 보세요.$140입니다.set Timeout 푸시
랜딩 페이지가 있습니다.'/'
사용자가 웹 사이트를 방문하면 5초 동안 로드하고 로그인으로 리다이렉트하고 싶은 로드 휠이 있습니다.'/login'
페이지입니다.
저는 Vue와 Bulma.io를 사용하고 있으며 랜딩에서 사용하고 있습니다.가지고 있는 vue 페이지:
<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>
라우터/index.js에는 다음이 있습니다.
/*
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 they are needed
routes: [
{
path: '/home', // this is the path in the URL
name: 'Home',
component: Home // created component
},
{
path: '/login', // this is the path in the URL
name: 'Login',
component: Login // created component
},
{
path: '/', // this is the path in the URL
name: 'Landing',
component: Landing // created component
}
]
})
<스크립트> 섹션의 기능에 문제가 있을 수 있습니다.
도와주셔서 감사합니다.
스크립트 섹션을 정의하는 경우 실제 Vue 구성 요소를 내보내야 합니다.
<script>
export default {
created(){
setTimeout( () => this.$router.push({ path: '/login'}), 5000);
}
}
</script>
언급URL : https://stackoverflow.com/questions/46761019/vue-this-router-push-in-settimeout
반응형
'programing' 카테고리의 다른 글
Nuxt.js 스토어, 다른 스토어에 디스패치액션 (0) | 2022.07.02 |
---|---|
구성 [Spring-Boot]에서 '패키지' 유형의 빈을 정의하는 것을 검토하십시오. (0) | 2022.07.02 |
vuex에서 getter의 특별한 용도는 무엇입니까? (0) | 2022.07.02 |
Vuex getter의 v-if (0) | 2022.07.01 |
JSONObject를 반복하는 방법 (0) | 2022.07.01 |