Просмотр исходного кода

update Web/src/App.vue.
当 Local.get('themeConfig') 返回 null(比如首次访问应用或本地存储被清除时),会出现"Cannot read properties of null (reading 'globalI18n')"错误。

如下:
App.vue:32 Uncaught TypeError: Cannot read properties of null (reading 'globalI18n')
at setup (App.vue:32:1)
at callWithErrorHandling (runtime-core.esm-bundler.js:199:19)
at setupStatefulComponent (runtime-core.esm-bundler.js:7998:25)
at setupComponent (runtime-core.esm-bundler.js:7959:36)
at mountComponent (runtime-core.esm-bundler.js:5287:7)
at processComponent (runtime-core.esm-bundler.js:5253:9)
at patch (runtime-core.esm-bundler.js:4769:11)
at render2 (runtime-core.esm-bundler.js:6064:7)
at mount (runtime-core.esm-bundler.js:4006:13)
at app.mount (runtime-dom.esm-bundler.js:1773:19)

Signed-off-by: 蓝猴子 <czieboy@live.cn>

蓝猴子 7 месяцев назад
Родитель
Сommit
a82893c4a4
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      Web/src/App.vue

+ 1 - 1
Web/src/App.vue

@@ -25,7 +25,7 @@ import { getAPI } from '/@/utils/axios-utils';
 import { useLangStore } from '/@/stores/useLangStore';
 import localeMap from '../lang/elementLocales'
 
-const currentLang = Local.get('themeConfig')['globalI18n'] || 'zh-cn'
+const currentLang = Local.get('themeConfig')?.globalI18n || 'zh-cn'
 const locale = computed(() => localeMap[currentLang] || localeMap['zh-cn'])
 
 // 引入组件