Skip to content

Commit

Permalink
refactor(useI18n): 不刷新修改
Browse files Browse the repository at this point in the history
  • Loading branch information
nihaojob committed Jul 29, 2023
1 parent c50cc3c commit 9bc6e9a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/components/lang.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @version:
* @Author: June
* @Date: 2023-05-20 09:18:28
* @LastEditors: June
* @LastEditTime: 2023-05-20 22:53:50
* @LastEditors: 秦少卫
* @LastEditTime: 2023-07-29 22:24:03
-->
<template>
<Dropdown @on-click="setLang">
Expand All @@ -26,7 +26,9 @@
import { setLocal } from '@/utils/local';
import { LANG } from '@/config/constants/app';
const $i18n = getCurrentInstance().appContext.config.globalProperties.$i18n;
import { useI18n } from 'vue-i18n';
const { locale } = useI18n();
const LANGMAP = {
zh: '中文',
en: 'En',
Expand All @@ -37,14 +39,13 @@ let langList = reactive(
);
const lang = computed(() => {
return LANGMAP[$i18n.locale];
return LANGMAP[locale.value];
});
// 设置语言
const setLang = (type) => {
$i18n.locale = type;
locale.value = type;
setLocal(LANG, type);
window.location.reload();
};
</script>

Expand Down

0 comments on commit 9bc6e9a

Please sign in to comment.