diff --git a/packages/reactivity/src/ref.ts b/packages/reactivity/src/ref.ts index a72e52090dd..797bf9c102b 100644 --- a/packages/reactivity/src/ref.ts +++ b/packages/reactivity/src/ref.ts @@ -182,15 +182,19 @@ class RefImpl { * @see {@link https://vuejs.org/api/reactivity-advanced.html#triggerref} */ export function triggerRef(ref: Ref): void { - if (__DEV__) { - ;(ref as unknown as RefImpl).dep.trigger({ - target: ref, - type: TriggerOpTypes.SET, - key: 'value', - newValue: (ref as unknown as RefImpl)._value, - }) - } else { - ;(ref as unknown as RefImpl).dep.trigger() + // ref may be an instance of ObjectRefImpl + const dep = (ref as unknown as RefImpl).dep + if (dep) { + if (__DEV__) { + dep.trigger({ + target: ref, + type: TriggerOpTypes.SET, + key: 'value', + newValue: (ref as unknown as RefImpl)._value, + }) + } else { + dep.trigger() + } } }