I've encountered an issue with using the route.meta property in my Vue 3 project. Initially, I had it working inside a Vue component, but when I moved the code into a .ts file, it stopped functioning and an error appeared in the browser.
Here is my .ts file:
import { useRoute } from "vue-router";
import { computed } from "vue";
const route = useRoute();
export const myfunction = computed(() => {
return route.meta.somedata;
});
The error displayed in the browser is:
Uncaught (in promise) TypeError: Cannot read property 'meta' of undefined
Interestingly, the same code works perfectly in .vue files. Is there a solution to access the meta property outside of the .vue file?