some params is missing when use localePath
See original GitHub issueMy reload params is missing to nuxt-link like this
<nuxt-link :to="localePath({ name: 'foo', params: { foo: 'nice', reload: true } })">
this.$router.push(localePath({ name: 'foo', params: { foo: 'nice', reload: true } }))
It’s working fine below. No params are lost.
<nuxt-link :to="{ name: 'foo', params: { foo: 'nice', reload: true } }">
this.$router.push({ name: 'foo', params: { foo: 'nice', reload: true } })
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:8
Top Results From Across the Web
some params is missing when use localePath #43 - GitHub
My reload params is missing to nuxt-link like this this.$router.push(localePath({ name: ... some params is missing when use localePath #43.
Read more >vue.js - How to access route params: through a fully nuxt-i18n ...
PS: localePath alone will not work because it will return a full path but you cannot use params with a path as explained...
Read more >Basic Usage - i18n-module
localePath – Returns the localized URL for a given page. The first parameter can be either the path or name of the route...
Read more >Rails Internationalization (I18n) API - Ruby on Rails Guides
The i18n library takes a pragmatic approach to locale keys (after some discussion), including only the locale ("language") part, like :en , :pl...
Read more >AnnotationClassLoader.php | Drupal 9.1.x | Drupal API
Most of the * time, this method should define some PHP callable to be called for the route ... $localePath; } } elseif...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I use a similar strategy to link to a child url (for SEO purposes), but also passing an id that I use to fetch data from.
Without i18n, you can do
<nuxt-link :to="{name: 'thepage-url', params: {id: '123', url: 'abced' }"} />
which will give you access to both parameters in $routes.params object on the child page.However, with i18n, when you write:
<nuxt-link :to="localePath({ name: 'thepage-url', params: {id: '123', url: 'abced'} })
you only access the parameter used for the ‘slug’ definition (this case, ‘url’).Have to use the alternative presented by @azeranex to make it work (thanks!), but feels like a hack. Edit: here’s what I use for Nuxt 2.4.0 and above:
IMO localePath() should deal only with the ‘name’, like
<nuxt-link :to="{ name: localePath('thepage-url'), params: { [ all we need here ]} }) />
What’s the benefit of passing the full params object into the function localePath?
I use reload param to check whether I need to fetch api data and fill vuex store or not. You can use query to track too but when you use ajax to fill more data (e.g. infinite scroll) your page will be reload to first data if you view item on other page and click back. You ajax content got wiped. Your scroll position lost.
If you store reload var in param you data still intact.
I can solve my problem by using (it’s work fine)
<nuxt-link :to="{ name: `listing-${$i18n.locale}`, params: { listing: 'rent', reload: true } }" class="navbar-item">{{ $t('navbar.rent') }}</nuxt-link>