[Vuejs]-Resume adding rows on history back and forward

1👍

There were a couple of changes done by me to fix your code

Firstly, you were trying to pass localChanges to parent which is getting initialized on each component load which is resetting your array. It is fixed by using

this.changesA.push({ ...obj });
this.changesB.push({ ...obj });
this.$emit("update:changesA", [...this.changesA]);
this.$emit("update:changesB", [...this.changesB]);

Secondly, in your firstObjects() method, you were pushing an item at index on obj as

this.changesB.push({ ...obj[i] }); //see i

which is wrong

Also, I think you want to call firstObjects() only if the array is empty which can be done by simply putting an enclosing condition.

Fixed sandbox: https://codesandbox.io/s/live-stats-with-pause-on-route-change-lqmqo

0👍

There is the keep-alive; as shown in Vue documentation.

<keep-alive>
  <component v-bind:is="statistics"></component>
</keep-alive>

Vue Documentation:
https://v2.vuejs.org/v2/guide/components-dynamic-async.html

Leave a comment