N
Nuxt2y ago
TorErik

localePath issue

In nuxt 2 I have this code to generate links to a given route name:
nuxtApp.$localePath({
name: routeName,
params: {
site: siteStore.siteName,
module: currentModule,
group: params.group,
}
})
nuxtApp.$localePath({
name: routeName,
params: {
site: siteStore.siteName,
module: currentModule,
group: params.group,
}
})
According to this: https://github.com/vuejs/router/blob/main/packages/router/CHANGELOG.md#414-2022-08-22 params is now ignored in vue-router: I have read the docs, but the language is confusing to me. I don't understand how to rewrite it to make it work as intended. Can someone ELI5 what the recommended approach is?
GitHub
router/CHANGELOG.md at main · vuejs/router
🚦 The official router for Vue.js. Contribute to vuejs/router development by creating an account on GitHub.
3 Replies
Fabian B.
Fabian B.2y ago
Hi, have you tried
const router = useRouter()
router.resolve({ name: '', params: {} })
const router = useRouter()
router.resolve({ name: '', params: {} })
? Or, if you use i18n,
const localePath = useLocalePath() // this is a composable from @nuxtjs/i18n
localePath({ name: '', params: {} })
const localePath = useLocalePath() // this is a composable from @nuxtjs/i18n
localePath({ name: '', params: {} })
TorErik
TorErikOP2y ago
With router I get Error: No match for { "name":"sitename","params":{"site":"mySite","module":"messages","group":"private" }} For some reason I can access sitename/messages/private directly with no issues, but if I want to retrieve the url with localePath its not found.
Fabian B.
Fabian B.2y ago
If your route is /sitename/messages/private shouldnt the name be "sitename-messages-private"? you can console.log the "router" variable from useRouter to see all your generated route names
Want results from more Discord servers?
Add your server