rt-sim-training-client/src/layout/components/Language.vue

64 lines
1.3 KiB
Vue
Raw Normal View History

2019-08-29 17:16:33 +08:00
<template>
<el-dialog
v-dialogDrag
2019-08-29 17:16:33 +08:00
:title="$t('global.switchLanguage')"
:visible.sync="visible"
width="360px"
:before-close="doClose"
class="language_box"
2019-08-29 17:16:33 +08:00
>
<div style="">
<span>{{ $t('global.language') }}</span>
<el-select v-model="lang" :placeholder="$t('global.chooseLanguage')">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">{{ $t('global.cancel') }}</el-button>
<el-button type="primary" @click="handleConfirm">{{ $t('global.confirm') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import LangStorage from '@/utils/lang';
export default {
data() {
return {
visible: false,
lang: '',
options: [
{value: 'zh', label: '中文'},
{value: 'en', label: 'English'}
]
};
},
methods: {
doShow() {
this.visible = true;
this.lang = LangStorage.getLang('zh');
},
doClose() {
this.visible = false;
},
handleConfirm() {
this.$i18n.locale = this.lang;
LangStorage.setLang(this.lang);
this.doClose();
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss">
.language_box .el-dialog__header{
padding: 0 20px 10px;
}
</style>