[Vuejs]-Vue.js root instance error

0👍

There seems to be two things problematic in your code:

  1. scope of this got changed inside $.get, due to which it is not assigning to the Vue instance variable.

  2. File Name test.json has to be in quotes.

You have to make following changes:

methods: {
fetchTestData: function () {
    var that = this
    $.get("test.json", function (data) {
        that.test_data = data;
        alert(this.test_data.isActive);
    });
}

Leave a comment