vue3中使用路由

import { useRouter, useRoute, ref } from 'vue-router';
const router = useRouter();
const route = useRoute()
// 获取所有的路由
const routes = router.getRoutes();
// 获取当前路由
let currentRoute = computed(() => router.currentRoute.value.path);
let storeId = ref('')
// 路由跳转
const goTo = (path: string) => {
  router.push({
    path: path
  })
}
onMounted(() => {
  storeId.value = route.query.storeId || ''
})

 

posted @ 2022-02-23 17:40  吃饭睡觉打痘痘  阅读(98)  评论(0编辑  收藏  举报