Сама функция переключения
в компьютед-свойстах делать сайд-эффекты - плохая практика
<v-btn class="font-weight-regular ml-3" style="background: #1F6BA7" fab flat small @click="switchLocale()">
{{ displayLocale.toLocaleUpperCase() }}
</v-btn>
computed: {
displayLocale() {
return this.$i18n.locale === 'ru' ? 'en' : 'ru'
}
}
watch: {
$route(to, from) {
//document.title = to.meta.title || '';
document.title = to.meta.title ? to.meta.title() || '' : '';
},
},
import Vue from 'vue'
import App from './App'
import Vuetify from 'vuetify'
import router from './router'
import axios from 'axios'
import VueI18n from 'vue-i18n'
import store from './store';
import english from '@/lang/english.js'
import russian from '@/lang/russian.js'
Vue.use(VueI18n)
let messages = {
en : english,
ru : russian,
}
const i18n = new VueI18n({
//locale: 'ru',
locale: window.localStorage.Language || 'ru',
fallbackLocale: 'ru',
messages
})
Vue.config.productionTip = false
Vue.use(Vuetify)
Vue.axios = Vue.prototype.$http = axios.create({
baseURL: 'http://localhost:5000/api'
})
/* eslint-disable no-new */
new Vue({
el: '#app',
i18n,
router,
store,
components: { App },
template: '<App/>',
created() {
this.$vuetify.theme.primary = '#01579B'
}
})