vue3关于路由query传参

传参
import { useRouter } from "vue-router"; 
const router = useRouter();
router.push({ path: "/Detail", query: { id:"123" } }); 
接受
import { useRoute } from "vue-router";
const route = useRoute();
console.log(route.query.id);

注意:
需要引入路由,在setup()创建对象,再使用,区分引入路由不同
传参是router, 引入useRouter
接收参数是route, 引入useRoute

你可能感兴趣的:(VUE,vue)