vue3 路由跳转携带参数以及其他页面接收参数
vue3 路由跳转携带参数以及其他页面接收参数
传参页面
<script setup>
import { useRouter } from "vue-router";
const router = useRouter();
// 路由
const goToDetail = () => {
router.push({ path: '/about', query: { id: 123 } });
};
function goToDetail(){
// router.push({ path: `/about` });
router.push({ path: '/about', query: { id: 123 } });
}
</script>
接收参数页面(about)
<script setup>
// 没有r
import { useRoute } from "vue-router";
const route = useRoute();
console.log(route.query.id,'页面接收到的值')
</script>