[Vuejs]-How can I save data from my calculator with cookie in vue?

0๐Ÿ‘

โœ…

 mounted() {
    if (localStorage.data) {
      this.data = JSON.parse(localStorage.data);
    }
  },
  watch: {
    data(newData) {
      localStorage.data = newData;
    }
  }

You could do something like this to save your data in local storage, and then load it on a page refresh. Or you can move the watcher into method and have it be triggered by "save" button.

Leave a comment