提交 95293905 编写于 作者: fxy060608's avatar fxy060608

fix(h5): expose getApp

上级 2fa3a616
...@@ -1855,15 +1855,9 @@ function initAppVm(appVm) { ...@@ -1855,15 +1855,9 @@ function initAppVm(appVm) {
const locale = ref(useI18n().getLocale()); const locale = ref(useI18n().getLocale());
Object.defineProperty(appVm, '$locale', { Object.defineProperty(appVm, '$locale', {
get() { get() {
{
uni.$nvueState && uni.$nvueState.locale;
}
return locale.value; return locale.value;
}, },
set(v) { set(v) {
{
uni.$nvueState && (uni.$nvueState.locale = v);
}
locale.value = v; locale.value = v;
}, },
}); });
......
...@@ -16,15 +16,9 @@ export function initAppVm(appVm: ComponentPublicInstance) { ...@@ -16,15 +16,9 @@ export function initAppVm(appVm: ComponentPublicInstance) {
const locale = ref<string>(useI18n().getLocale()) const locale = ref<string>(useI18n().getLocale())
Object.defineProperty(appVm, '$locale', { Object.defineProperty(appVm, '$locale', {
get() { get() {
if (__PLATFORM__ === 'app') {
;(uni as any).$nvueState && (uni as any).$nvueState.locale
}
return locale.value return locale.value
}, },
set(v) { set(v) {
if (__PLATFORM__ === 'app') {
;(uni as any).$nvueState && ((uni as any).$nvueState.locale = v)
}
locale.value = v locale.value = v
}, },
}) })
......
...@@ -85,7 +85,7 @@ function registerGlobalCode(config: ResolvedConfig, ssr?: boolean) { ...@@ -85,7 +85,7 @@ function registerGlobalCode(config: ResolvedConfig, ssr?: boolean) {
if (enableTreeShaking && config.command === 'build' && !ssr) { if (enableTreeShaking && config.command === 'build' && !ssr) {
// 非 SSR 的发行模式,补充全局 uni 对象 // 非 SSR 的发行模式,补充全局 uni 对象
return `import { upx2px } from '@dcloudio/uni-h5';${name}.uni = {};${name}.wx = {};${name}.rpx2px = upx2px` return `import { upx2px, getApp } from '@dcloudio/uni-h5';${name}.uni = {};${name}.wx = {};${name}.rpx2px = upx2px`
} }
return ` return `
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册