Skip to content

Commit

Permalink
Merge pull request #244 from jaitaiwan/f/vue3-support
Browse files Browse the repository at this point in the history
  • Loading branch information
championswimmer authored Dec 9, 2021
2 parents 4d04279 + b1b714a commit 03d0128
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,13 @@ export class VuexPersistence<S> implements PersistOptions<S> {
this.RESTORE_MUTATION = function RESTORE_MUTATION(state: S, savedState: any) {
const mergedState = merge(state, savedState || {}, _this.mergeOption)
for (const propertyName of Object.keys(mergedState as {})) {
(this as any)._vm.$set(state, propertyName, (mergedState as any)[propertyName])
// Maintain support for vue 2
if ((this as any)._vm !== undefined && (this as any)._vm.$set !== undefined) {
(this as any)._vm.$set(state, propertyName, (mergedState as any)[propertyName])
continue
}

(state as any)[propertyName] = (mergedState as any)[propertyName]
}
}

Expand Down

0 comments on commit 03d0128

Please sign in to comment.