[Vuejs]-How can I get data from json file using vue js 2?

0👍

You have a scoping issue: this within the callback does not refer to your Vue instance. That is because you are not using ES6 arrow function, i.e.:

this.$http.get('http://localhost:8080/api.js').then(response => {
    this.list = response.data
});

…which means the outer this is not passed in. You will have to proxy that yourself, i.e. var self = this on the outside, and then use self.list = response.data:

var self = this;
this.$http.get('http://localhost:8080/api.js').then(response => {
    self.list = response.data
});

Leave a comment