[Vuejs]-I am new to vue js … can't display loaded data from a php file

0👍

Well, this isn’t that

created:function () {
    this.$http.get('index.php').then(function(resp,status,request){
        this.items = resp.data; // this is referring to the current function, and not to vue's scope.
        console.log(this.items); // got data but not displayed in  browser
    }.bind(this));
}

So the correct use is:

created:function () {
    var self = this
    this.$http.get('index.php').then(function (resp,status,request) {
        self.items = resp.data;
        console.log(this.items);
    });
}

0👍

As MU commented above, better you to use Arrows functions, so the “this” will have the scope you want.

mounted () {
}

Then you can access all your Data properties normally with “this”.

Leave a comment