feat(reactivity): provide correct tracking info for refs

This commit is contained in:
Evan You 2019-11-02 23:20:49 -04:00
parent 7f054782ad
commit f3c1fa75f6

View File

@ -24,12 +24,17 @@ export function ref(raw?: unknown) {
const r = {
_isRef: true,
get value() {
track(r, OperationTypes.GET, '')
track(r, OperationTypes.GET, 'value')
return raw
},
set value(newVal) {
raw = convert(newVal)
trigger(r, OperationTypes.SET, '')
trigger(
r,
OperationTypes.SET,
'value',
__DEV__ ? { newValue: newVal } : void 0
)
}
}
return r as Ref