0

I am working on an HTML Poster Generator using Vue.js. I would like to save all the data as JSON and load all the data again from JSON.

I thought that this would be straight forward but the way I searched (maybe new to Vue.js) I did not find a way to load and save the whole data object. That would be this?

I would like something like this:

export default Vue.extend({
  // ...
  computed: {
    getDataAsJSON() {
      return JSON.stringify(this);
    },
    setDataAsJSON(data) {
      this.data = JSON.parse(data);
    }
  }

I will investigate further. Answers welcome.

Research:

User
  • 14,131
  • 2
  • 40
  • 59

1 Answers1

0
...
    getDataAsJSON() {
      return JSON.stringify(this.data);
                                  
    },
...
tauzN
  • 5,162
  • 2
  • 16
  • 21
  • `this.data` seems `undefined` to me. Do you have a link to documentation? – User Dec 06 '22 at 20:43
  • 1
    You need to define data, then. In the data object. https://vuejs.org/api/options-state.html#data – tauzN Dec 06 '22 at 20:47