-
-
Notifications
You must be signed in to change notification settings - Fork 477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
useRoute('login') does not work, it expects useRoute('login__LOCALE') #2976
Comments
on the login page So you can use 'name' as |
@martijndewit That didn't work. I still see |
How did you set your Routing Strategy ? |
Would you be able to provide a reproduction? 🙏 More infoWhy do I need to provide a reproduction?Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making. What will happen?If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect. If How can I create a reproduction?We have a couple of templates for starting with a minimal reproduction: 👉 Reproduction starter (v8 and higher) A public GitHub repository is also perfect. 👌 Please ensure that the reproduction is as minimal as possible. See more details in our guide. You might also find these other articles interesting and/or helpful: |
Same issue, why route names are localized by default? It makes code extremely unreadable and quite doesn't make sense. Every time I need to resolve a route path, I need to figure out the current locale and then suffix it with that locale. I think you should be able to just reference the route name without a locale, and it resolves into a path with the current locale. |
How do you reproduce this with stackblitz? As far as I've tried there are no type hints on stackblitz with nuxt(vue). https://stackblitz.com/edit/github-zep9gz-2odmdq?file=pages%2Ftest.vue |
This is related to route We try to make this behavior easier to deal with by providing composables such as |
@BobbieGoede Only this works, but nowhere did I get any hints that slug is even a possible key of params... There are also no type hints that I'm guessing that this example is not even possible if you have <script setup>
const localeRoute = useLocaleRoute()
const { locale } = useI18n()
const linkPath = computed(() => {
const route = localeRoute('blog', locale.value)
return route != null ? route.path : '/'
})
</script> |
I spent some time in the past week to see what it would take to have most of the type inference for these route composables/functions. Here's what I have so far BobbieGoede#49, this branch contains lots of duplicated code from both Vue Router and Nuxt, and relies on their internals so it's not anywhere close to being stable.. I will check with their maintainers at some point and see if I could make something happen for v9 but I'm not very optimistic that this is something they want to support/expose downstream. |
The only way that I've found to be able to get IDE autocomplete for route params is to use one of the locale like this const route = useRoute('login___en')
route.params.id // autocomplete works now |
I am using this as a workaround, but it would be great not to have to. const localeRoute = useLocaleRoute()
localeRoute({ name: 'users.edit' as 'users.edit___en', params: { id: row.id } }) |
I have just published the first release candidate for v9 which includes the experimental typed routes Try it out and please open new issues if you experience any with this feature 🙏 |
Environment
N/A
Reproduction
N/A
Describe the bug
Nuxt i18n module has support for Nuxt typedPages but I can't understand how to use it.
Nuxt docs says:
But I don't have one
route-name
when using i18n. I don't have alogin
route. Instead I havelogin__en
,login__de
,login__fr
etc.Passing in simply "login" does not work
useRoute('login')
, it expects a locale which is very strange. How do I use this? I couldn't find anything in the docs.Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: