From 32dfbb16457673e294999311c6b763fbd6ff2193 Mon Sep 17 00:00:00 2001 From: DCloud_LXH <283700113@qq.com> Date: Wed, 3 Aug 2022 20:08:24 +0800 Subject: [PATCH] fix(h5): leftWindow props update error question/149618 --- .../src/framework/components/layout/index.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/uni-h5/src/framework/components/layout/index.tsx b/packages/uni-h5/src/framework/components/layout/index.tsx index b648308b5..47d6ea60d 100644 --- a/packages/uni-h5/src/framework/components/layout/index.tsx +++ b/packages/uni-h5/src/framework/components/layout/index.tsx @@ -16,6 +16,7 @@ import { Ref, watch, nextTick, + WritableComputedRef, } from 'vue' import { RouterView } from 'vue-router' @@ -273,7 +274,7 @@ function useState() { () => layoutState.rightWindowWidth + layoutState.marginWidth, (value) => updateCssVar({ '--window-right': value + 'px' }) ) - const windowState: WindowState = reactive({ + const windowState: WritableComputedRef = computed(() => ({ matchTopWindow: layoutState.topWindowMediaQuery, showTopWindow: layoutState.showTopWindow || layoutState.apiShowTopWindow, matchLeftWindow: layoutState.leftWindowMediaQuery, @@ -281,7 +282,7 @@ function useState() { matchRightWindow: layoutState.rightWindowMediaQuery, showRightWindow: layoutState.showRightWindow || layoutState.apiShowRightWindow, - }) + })) return { layoutState, windowState, @@ -291,7 +292,7 @@ function useState() { function createLayoutTsx( keepAliveRoute: KeepAliveRoute, layoutState?: LayoutState, - windowState?: WindowState, + windowState?: WritableComputedRef, topWindow?: unknown, leftWindow?: unknown, rightWindow?: unknown @@ -304,13 +305,13 @@ function createLayoutTsx( return routerVNode } const topWindowTsx = __UNI_FEATURE_TOPWINDOW__ - ? createTopWindowTsx(topWindow, layoutState!, windowState!) + ? createTopWindowTsx(topWindow, layoutState!, windowState!.value) : null const leftWindowTsx = __UNI_FEATURE_LEFTWINDOW__ - ? createLeftWindowTsx(leftWindow, layoutState!, windowState!) + ? createLeftWindowTsx(leftWindow, layoutState!, windowState!.value) : null const rightWindowTsx = __UNI_FEATURE_RIGHTWINDOW__ - ? createRightWindowTsx(rightWindow, layoutState!, windowState!) + ? createRightWindowTsx(rightWindow, layoutState!, windowState?.value!) : null return (