fix: 挂载前根据默认语言在设置一次
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { computed } from 'vue';
|
||||
import { computed, onBeforeMount } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { localSet } from '@/utils/cache-local-utils';
|
||||
import { localGet, localSet } from '@/utils/cache-local-utils';
|
||||
import { CACHE_LOCAL_I18N } from '@/constants/cache-keys-constants';
|
||||
|
||||
export default function useLocale() {
|
||||
@@ -31,6 +31,14 @@ export default function useLocale() {
|
||||
},
|
||||
];
|
||||
|
||||
// 挂载前根据默认语言在设置一次
|
||||
onBeforeMount(() => {
|
||||
const localI18n = localGet(CACHE_LOCAL_I18N);
|
||||
if (localI18n) {
|
||||
i18n.locale.value = localI18n;
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
optionsLocale,
|
||||
currentLocale,
|
||||
|
||||
Reference in New Issue
Block a user