[Vuejs]-Vue isse with JSON data

0👍

You can compute that dict value directly in data but it’s better to do it in computed, like so:

computed: {
  dict() {
    return JSON.parse(JSON.stringify(document.getElementById('vuedata').innerHTML))
  }
}

You can then use that value in template, like you would normally use data properties:

<div>{{dict}}</div>

Or use it in other computed / methods by specifying this., example:

console.log(this.dict)

By the way, the data property should return the values, like this:

data() {
  return {
    dict1: ...,
    dict2: ...,
    ...
  }
}

Leave a comment