路由跳转

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才能显示二级路由,以此类推。

Logo

前往低代码交流专区

更多推荐