refactor(i18n): 根据官方提示重构 i18n,全部功能正常

This commit is contained in:
菲鸽
2024-01-29 19:56:25 +08:00
parent 852b6e70ef
commit 2416faedca
9 changed files with 31 additions and 22 deletions

View File

@@ -29,13 +29,13 @@
</template>
<script lang="ts" setup>
import { getLocale } from '@/locales/index'
import i18n from '@/locale/index'
import { testI18n } from '@/utils/index'
const current = ref(getLocale())
const current = ref(uni.getLocale())
const languages = [
{
value: 'zh',
value: 'zh-Hans',
name: '中文',
checked: 'true',
},
@@ -48,8 +48,9 @@ const languages = [
const radioChange = (evt) => {
// console.log(evt)
current.value = evt.detail.value
// https://uniapp.dcloud.net.cn/api/ui/locale.html#setlocale
// 下面2句缺一不可
uni.setLocale(evt.detail.value)
i18n.global.locale = evt.detail.value
}
</script>
@@ -79,3 +80,4 @@ const radioChange = (evt) => {
background-color: #bcecd1;
}
</style>
@/locale/index