<template>
<div>
<!-- 写路由系统的占位符 -->
<router-view />
<!-- 路由组件的标签跳转 -->
<router-link to="/">Home</router-link>
<router-link to="/about">About</router-link>
<!-- 编程式跳转 -->
<button @click="gozhu">3秒后跳转到zhu</button>
</div>
</template>
<script>
export default {
methods: {
gozhu() {
//定时器
var num = 3
//在后台找有没router
console.log(this)
const a = setInterval(() => {
num--
console.log('num:', num)
if (num == 0) this.$router.push('/zhu')
// 清除定时器
clearInterval(a)
}, 1000)
}
}
}
</script>
<style lang="scss" scoped>
</style>
vue的路由组件编程式跳转
最新推荐文章于 2024-07-17 20:15:37 发布