vue3 路由跳转&router-view
路由跳转router-link<router-link to="/login">去登陆</router-link>点击事件跳转<template><button @click="goHome">去首页</button></template><script>export default{methods:{goHome
·
路由跳转
router-link
<router-link to="/login">去登陆</router-link>
点击事件跳转
<template>
<button @click="goHome">去首页</button>
</template>
<script>
export default{
methods:{
goHome(){
this.$router.push('/home')
}
}
}
</script>
Composition API跳转
<script setup>
import {useRouter} from 'vue-router'
let router = useRouter()
const goHome = ()=>{
router.push('home')
}
</script>
router-view
一层套一层嘛,app.vue的router-view显示一级路由,一级路由有router-view才能显示二级路由,以此类推。
更多推荐
已为社区贡献3条内容
所有评论(0)