diff --git a/src/core/runtime/locale.js b/src/core/runtime/locale.js index 2b358f323385033f7c0f82b6cfbc270638836e3d..02029d5b0679a22677262de4a973dd993252fb28 100644 --- a/src/core/runtime/locale.js +++ b/src/core/runtime/locale.js @@ -1,18 +1,21 @@ import { normalizeLocale, LOCALE_EN } from '../helpers/i18n/index' +import { isFn } from 'uni-shared' export function getLocale () { // 优先使用 $locale - const app = getApp({ - allowDefault: true - }) - if (app && app.$vm) { - return app.$vm.$locale + if (isFn(getApp)) { + const app = getApp({ + allowDefault: true + }) + if (app && app.$vm) { + return app.$vm.$locale + } } return normalizeLocale(__GLOBAL__.getSystemInfoSync().language) || LOCALE_EN } export function setLocale (locale) { - const app = getApp() + const app = isFn(getApp) ? getApp() : false if (!app) { return false }