就useRoute和 useRouter分别对应vue2中的this.$routethis.$router其他的使用方法都一样

import { useRoute, useRouter, onBeforeRouteUpdate } from "vue-router";

setup(){
const route = useRoute();
const router = useRouter();
console.log(route.query)
router.push({path:'/home'})
onBeforeRouteUpdate((to: any) => {
      console.log(to, "=====");
 });
}

Logo

前往低代码交流专区

更多推荐