fix: added setter for intial value, closes #333

This commit is contained in:
Guillaume Chau
2018-09-08 15:46:43 +02:00
parent 2449333d07
commit ff040a1db1
+8
View File
@@ -30,6 +30,7 @@ function proxyData () {
let apollo = this.$options.apollo
if (apollo) {
this.$_apolloInitData = {}
// watchQuery
for (let key in apollo) {
if (key.charAt(0) !== '$') {
@@ -38,6 +39,8 @@ function proxyData () {
if (!options.manual && !hasProperty(this.$options.props, key) && !hasProperty(this.$options.computed, key) && !hasProperty(this.$options.methods, key)) {
Object.defineProperty(this, key, {
get: () => this.$data.$apolloData.data[key],
// For component class constructor
set: value => this.$_apolloInitData[key] = value,
enumerable: true,
configurable: true,
})
@@ -81,6 +84,11 @@ function launch () {
configurable: true,
})
// Init data
for (let key in this.$_apolloInitData) {
this.$set(this.$data.$apolloData.data, key, this.$_apolloInitData[key])
}
// watchQuery
for (let key in apollo) {
if (key.charAt(0) !== '$') {