You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
720 B

6 months ago
6 months ago
  1. <template>
  2. <el-config-provider :locale="elLocale">
  3. <router-view />
  4. </el-config-provider>
  5. </template>
  6. <script setup>
  7. import { computed } from 'vue'
  8. import { useI18n } from 'vue-i18n'
  9. // 引入 Element Plus 的语言包
  10. import zhCnLocale from 'element-plus/dist/locale/zh-cn.mjs'
  11. import enLocale from 'element-plus/dist/locale/en.mjs'
  12. import thLocale from 'element-plus/dist/locale/th.mjs'
  13. const { locale } = useI18n()
  14. // 计算属性:根据当前 i18n 的语言,返回对应的 Element Plus 语言包
  15. const elLocale = computed(() => {
  16. switch (locale.value) {
  17. case 'zh-CN': return zhCnLocale
  18. case 'en': return enLocale
  19. case 'th': return thLocale
  20. default: return zhCnLocale
  21. }
  22. })
  23. </script>