Created
December 4, 2019 11:37
-
-
Save Bachana123/0d280fd2145ea3359fbf0c57ed700ef8 to your computer and use it in GitHub Desktop.
better localePath for NUXT!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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