Skip to content

Instantly share code, notes, and snippets.

@Bachana123
Created December 4, 2019 11:37
Show Gist options
  • Save Bachana123/0d280fd2145ea3359fbf0c57ed700ef8 to your computer and use it in GitHub Desktop.
Save Bachana123/0d280fd2145ea3359fbf0c57ed700ef8 to your computer and use it in GitHub Desktop.
better localePath for NUXT!
// fixed nested link routing problem Instead localePath
import Vue from 'vue'
Vue.mixin({
methods: {
localeLink(link,lang = ''){
link = link.split("/").filter(item => item !="").join("/");
if(lang!='')
return lang === this.$i18n.defaultLocale ? '/'+link : '/'+lang+'/'+link;
else if(this.$i18n.locale === this.$i18n.defaultLocale)
return '/'+link;
else if(link === '')
return '/'+this.$i18n.locale
return '/'+this.$i18n.locale+'/'+link;
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment