Change Lang

Basic usage

<mu-change-lang 
    :current-language="routerLang" 
    :all-languages="allLanguages" 
    position="bottom" 
    style-dropdown="gray"
    v-on:changelang="changeLang"
/>
1
2
3
4
5
6
7
export default {
    data() {
        return {
            lang: 'en',
            allLanguages: ['ru', 'en', 'es']
        }
    },
    computed: {
        routerLang() {
            return  this.lang
        }
    },
    methods: {
        changeLang(lang){
            this.lang = lang;
            console.log('Language:', lang)
        }
    },
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

Attributes

Attribute Description Type Accepted Values Default
currentLanguage Current page language String any 'ru'
allLanguages Available languages of the page Array Array of strings Empty array
position Position of dropdown list String top / bottom / left / right Top
styleDropdown Style of dropdown String gray / ' ' Empty string
v-on: changeLang Event when clicking dropdown element Function any No events