首页 > TAG信息列表 > useRouter
编程式路由
import { useRouter } from 'vue-router' const router = useRouter() router.push({ path: "/about", query: { name: "why", age: 18 } }) 如何得到query呢 ? 模板中 : <h2>About: {{ $route.query }}</h2>vue3监听路由变化
1.onBeforeRouteUpdate路由守卫 import { useRouter, onBeforeRouteUpdate } from 'vue-router' let route = useRouter() onBeforeRouteUpdate(to=>{ console.log('to :>> ', to); }) 2.watch监听 import { useRouter, onBeforeRouteUpd