fix: detect property add/deletion on reactive objects from setup when used in templates

This commit is contained in:
Evan You 2022-07-12 18:59:26 +08:00
parent 98fb01c79c
commit a6e74985cf

View File

@ -119,7 +119,16 @@ export function proxyWithRefUnwrap(
Object.defineProperty(target, key, {
enumerable: true,
configurable: true,
get: () => unref(source[key]),
get: () => {
const val = source[key]
if (isRef(val)) {
return val.value
} else {
const ob = val && val.__ob__
if (ob) ob.dep.depend()
return val
}
},
set: value => {
const oldValue = source[key]
if (isRef(oldValue) && !isRef(value)) {