1. watch监听
import { watch} from 'vue'
import {useRouter} from 'vue-router'
let router = useRouter()
watch(() =>router.currentRoute._value,(m,n)=> {
console.log('watch',m)
},{ immediate: true })
2. onBeforeRouteUpdate 导航守卫
// f5 刷新不触发
import { onBeforeRouteUpdate } from 'vue-router'
onBeforeRouteUpdate((to) => {
console.log('to',to)
});
标签:vue,import,watch,onBeforeRouteUpdate,vue3,router,vite,监听,路由
From: https://www.cnblogs.com/zhang-hong/p/16945327.html