[Vuejs]-Adding elements from html node to vuejs data

2👍

Pass your tasks in as a prop:

<tasks :tasks="@json($tasks)"></tasks>

Then set up that prop in the component:

Vue.component('tasks', {
    template: `
        <div>
            <task v-for="task in tasks"> {{ task.name }} </task>
        </div>
    `,
    props:['tasks']
});

If you have a separate component for individual tasks you can again pass the task as a prop:

<task v-for="task in tasks" :task="task"></task>
👤Jeff

Leave a comment