vue3中使用router进行路由跳转

时间:2025-04-01 08:00:05

(1) 使用getCurrentInstance

const {ctx} =getCurrentInstace()

//获取路由信息
ctx.$root.$route
//进行路由跳转
ctx.$root.$router.push()

(2) 使用useRouter

import {useRouter} from 'vue-router'

const router=useRouter()

router.push()

相关文章