[Vuejs]-How can I get other root data in component under the v-for statement?

0👍

change this.$root.items to $root.items

0👍

You don’t have to prefix with this. when you’re inside the template of your component.

So, you just have to replace this.$root.items by $root.items and this.$root.string by $root.string.

However, you need to prefix with this. if you’re referencing the value inside your Vue object.

Example :

computed: {     
    exampleComputed: function () {
        return this.string;
     }
}

And the corrected JSFiddle : http://jsfiddle.net/89kgnrvf/19/

Leave a comment