[Vuejs]-Vue data referencing issue

0👍

You are getting the error

items is not defined

because of following line:

created: function () {
    console.log("Loading data...")

    this.loadData();

    console.log(items)   <== this should be console.log(this.items)

0👍

Turns out there was a few issues in my code.

1) As was pointed out by Saurabh, I forgot to put this.items instead of items.

2) this can’t be referenced inside of the function I defined as I have it… instead, the function has to be defined with =>, for example:

$.get('http://localhost:4567/getQueue').then((response) => {
        this.items = response.data.results;
        console.log("loadData finished - items length is: "+this.items.length)
    })

3) The big error I had was that my div bind with items was inside the table tag, which apparently isn’t okay to do. Instead I applied the Vue binds to the existing tags (table, tr).

Leave a comment