提交 5077e0fc 编写于 作者: D DCloud_LXH

fix(mp-weixin): getApp is not Function

上级 f6aac783
import { normalizeLocale, LOCALE_EN } from '../helpers/i18n/index' import { normalizeLocale, LOCALE_EN } from '../helpers/i18n/index'
import { isFn } from 'uni-shared'
export function getLocale () { export function getLocale () {
// 优先使用 $locale // 优先使用 $locale
const app = getApp({ if (isFn(getApp)) {
allowDefault: true const app = getApp({
}) allowDefault: true
if (app && app.$vm) { })
return app.$vm.$locale if (app && app.$vm) {
return app.$vm.$locale
}
} }
return normalizeLocale(__GLOBAL__.getSystemInfoSync().language) || LOCALE_EN return normalizeLocale(__GLOBAL__.getSystemInfoSync().language) || LOCALE_EN
} }
export function setLocale (locale) { export function setLocale (locale) {
const app = getApp() const app = isFn(getApp) ? getApp() : false
if (!app) { if (!app) {
return false return false
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册