In Vue2, I can use this.$route.path
In Vue3, I can use useRouter()
but in Vue2.7 composition api, both of them I can't use.
In Vue2, I can use this.$route.path
In Vue3, I can use useRouter()
but in Vue2.7 composition api, both of them I can't use.
For folks coming here from google:
Vue Router 3(current latest version is 3.6.5
) provides composables for you to use, check out release notes: https://github.com/vuejs/vue-router/blob/dev/CHANGELOG.md#360-2022-08-22
You would import it like so: import { useRouter, useRoute } from 'vue-router/composables';
And for the rest usage/docs you can refer to Vue Router 4 composable docs: https://router.vuejs.org/guide/advanced/composition-api.html