三種方式
import { defineComponent, ref, reactive, watch, toRaw, getCurrentInstance } from 'vue';
const { proxy }: any = getCurrentInstance();
console.log(proxy.$router.currentRoute.value);
const router = useRouter();
console.log(router.currentRoute.value);
watch(
() => router,
(newValue, oldValue) => {
console.log(newValue.currentRoute.value, '新的路由');
console.log(newValue.currentRoute.value, '舊的路由');
},
{ immediate: true }
);
