fix(reactivity): ensure computed can be wrapped by readonly

fix #3376
This commit is contained in:
Evan You
2021-03-25 11:23:26 -04:00
parent e4b5fccd0c
commit 41e02f0fac
2 changed files with 29 additions and 6 deletions

View File

@@ -48,12 +48,14 @@ class ComputedRefImpl<T> {
}
get value() {
if (this._dirty) {
this._value = this.effect()
this._dirty = false
// the computed ref may get wrapped by other proxies e.g. readonly() #3376
const self = toRaw(this)
if (self._dirty) {
self._value = this.effect()
self._dirty = false
}
track(toRaw(this), TrackOpTypes.GET, 'value')
return this._value
track(self, TrackOpTypes.GET, 'value')
return self._value
}
set value(newValue: T) {