diff --git a/components/_util/eagerComputed.ts b/components/_util/eagerComputed.ts index bc15ca9f28..f26980e30e 100644 --- a/components/_util/eagerComputed.ts +++ b/components/_util/eagerComputed.ts @@ -1,7 +1,14 @@ -import { watchEffect, shallowRef } from 'vue'; +import { watchEffect, shallowRef, version, computed } from 'vue'; import type { ComputedRef } from 'vue'; export declare type ComputedGetter = (...args: any[]) => T; export default function eagerComputed(fn: ComputedGetter) { + const currentVueVersion = Number(version.split('.').slice(0, 2).join('')); + + // version >= 3.4.x, use computed instead of watchSyncEffect + if (currentVueVersion >= 34) { + return computed(fn); + } + const result = shallowRef(); watchEffect( () => {