Skip to content

Commit f486d7e

Browse files
author
Guillaume Chau
committed
fix(ui): sharedData watchers
1 parent 2239e56 commit f486d7e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/@vue/cli-ui/src/util/shared-data.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ export default {
3232
}
3333
},
3434

35+
beforeCreate () {
36+
Object.defineProperty(this, '$sharedData', {
37+
get: () => this.$data.$sharedData,
38+
enumerable: true,
39+
configurable: true
40+
})
41+
},
42+
3543
created () {
3644
const options = this.$options.sharedData
3745
if (options) {
@@ -48,6 +56,11 @@ export default {
4856
} else {
4957
this.$syncSharedData(options)
5058
}
59+
// Force watchers to re-evaluate
60+
// Because we just added the proxies to this.$data.$sharedData[key]
61+
this._watchers.forEach(watcher => {
62+
watcher.update()
63+
})
5164
}
5265
},
5366

0 commit comments

Comments
 (0)