As the project ui framework uses element
, so international but also its internationalization. Complete code. At the same time the current lang
language exists cookie
in order to be able to remember the next time you open the page language set last.
# Global lang
Code Address: @ / lang currently configured with both English and Chinese languages.
At the same time @/lang/index.js
it introduced a element-ui
language pack
use:
// $t 是 vue-i18n 提供的全局方法,更多信息请查看其文档
$t('login.title')
# Asynchronous lang
There are only certain pages need lang, such as @/views/i18n-demo
page
import local from './local'
this.$i18n.mergeLocaleMessage('en', local.en) this.$i18n.mergeLocaleMessage('zh', local.zh)
#js use $ t
If you use such select
components, its value is through v-for
from, such as:
<el-select v-model="value"> <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"/> </el-select>
this.options = [
{ value: '1', label: this.$t('i18nView.one') }, { value: '2', label: this.$t('i18nView.two') }, { value: '3', label: this.$t('i18nView.three') } ]
In this case, international only once, because in js in this.options
time, it will not end with your local data and execute only during initialization lang
and change of change, so you need to lang
change the time manually reset set this.options
.
export default {
watch: { lang() { this.setOptions() } }, methods: { setOptions() { this.options = [ { value: '1', label: this.$t('i18nView.one') }, { value: '2', label: this.$t('i18nView.two') }, { value: '3', label: this.$t('i18nView.three') } ] } } }
http://www.eternelle.cn
http://www.yajuxuan.cn
http://www.nodonkg.cn
http://www.yurunyipinn.cn
http://www.niudangjiaa.cn
http://www.feikeshoubiaoo.cn
http://www.yumengse.cn
http://www.parniss.cn
http://www.sensefadd.cn
http://www.youmaqi.cn
http://www.yinghengg.cn
http://www.xizuann.cn
http://www.vapsint.cn
http://www.moshii.cn
http://www.shamandaweiyu.cn
http://www.taiguangyinlou.cn
http://www.dexidunn.cn
http://www.marbooo.cn