From 41772ba6f5365862f6b775933bb9c235b938fe16 Mon Sep 17 00:00:00 2001 From: Carl Chen Date: Sun, 23 Jun 2024 18:29:42 +0800 Subject: [PATCH] fix: adapt to changes in vue3.4+ --- components/_util/eagerComputed.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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( () => {