[Vuejs]-Cannot read property 'text' of undefined – Vue.js

3👍

Remove the colon before the v-for.

1👍

I’m not strong on Vue, but I don’t think you want the : on :v-for, just v-for:

const app = new Vue({
    el: '#app',
    data: {
        todos: [
            {
                text: "Subscibe to Renatello.com newsletter",
                done: true
            },
            {
                text: "Learn Vue",
                done: false
            },
            {
                text: "Build awesome projects",
                done: false
            }
        ]
    }
})

setTimeout(() => {
    app.todos = [
        ...app.todos,
        {
            text: "more",
            done: false
        }
    ];
}, 1000);
<div id="app">
    <ul>
        <li v-for="todo in todos">
            {{ todo.text }}
        </li>
    </ul>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>

Leave a comment