Based on the knowledge sources provided, there are a few important points to consider regarding the issue you're experiencing after updating to Nuxt 3.15:
-
There have been some changes in how route parameters are handled in Nuxt 3.15, particularly with definePageMeta and the useRoute() composable.
-
The code you've provided is using the Options API (mounted() hook) mixed with Composition API (useRoute()), which can lead to unexpected behavior.
-
In Nuxt 3, it's recommended to use the Composition API with <script setup> for better performance and consistency.
To address your specific issue:
-
The this.$route syntax is part of the Options API and may not work as expected when mixed with Composition API methods like useRoute().
-
useRoute() should be called within the setup() function or <script setup>, not inside lifecycle hooks like mounted().
-
The undefined token might be a result of these mixing issues or changes in how route parameters are processed in Nuxt 3.15.
To fix this, you should refactor your code to use the Composition API consistently. Here's an example of how you might rewrite your code:
<script setup>
import { onMounted } from 'vue'
import { useRoute } from 'vue-router'
const route = useRoute()
onMounted(() => {
console.log("Initialization")
console.log(route)
const token = route.params.token
console.log("token", token)
})
</script>
If you're still experiencing issues after refactoring, it might be related to changes in Nuxt 3.15. You can try setting the compatibility version to 3 in your nuxt.config.ts file as a temporary workaround:
export default defineNuxtConfig({
experimental: {
compatibilityVersion: '3'
}
})