diff --git a/packages/runtime-core/src/components/KeepAlive.ts b/packages/runtime-core/src/components/KeepAlive.ts index f2b7bdf9738..6910de2b3e0 100644 --- a/packages/runtime-core/src/components/KeepAlive.ts +++ b/packages/runtime-core/src/components/KeepAlive.ts @@ -55,6 +55,7 @@ export interface KeepAliveProps { include?: MatchPattern exclude?: MatchPattern max?: number | string + freeze?: boolean | string } type CacheKey = PropertyKey | ConcreteComponent @@ -88,6 +89,7 @@ const KeepAliveImpl: ComponentOptions = { include: [String, RegExp, Array], exclude: [String, RegExp, Array], max: [String, Number], + freeze: [String, Boolean], }, setup(props: KeepAliveProps, { slots }: SetupContext) { @@ -160,6 +162,10 @@ const KeepAliveImpl: ComponentOptions = { } }, parentSuspense) + if (props.freeze) { + instance.scope.resume() + } + if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) { // Update components tree devtoolsComponentAdded(instance) @@ -183,6 +189,10 @@ const KeepAliveImpl: ComponentOptions = { instance.isDeactivated = true }, parentSuspense) + if (props.freeze) { + instance.scope.resume() + } + if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) { // Update components tree devtoolsComponentAdded(instance)