属性 'push' 未定义 - vue.js

Property 'push' of undefined - vue.js

我正在尝试 vue.js 一点点,但在将项目推送到数组时遇到了一些问题。下面的代码基于 scrimba 教程,起初我对其进行了一些详细说明,但后来出现错误:"Uncaught typeError: Cannot read property 'push' of undefined".

所以我简化了它,直到我回到教程的基础知识。错误仍然存​​在..

let app = new Vue({
    el: '#toDoApp',
    data: {
        todos: [
            { text: 'Learn JavaScript' },
            { text: 'Learn Vue' },
            { text: 'Build something awesome' }
        ]
    }
});

toDoApp.todos.push({ text: 'New item' });

在推送语句之后,列表应该是 4 个项目,而不是我看到的 3 个。

我在网上读到一些东西说这可能是因为我试图分配给它的变量不是数组,但据我所知是。以及我发现这与教程代码之间没有任何区别的事实。

this.todos.push({ text: 'New item' });

app.todos.push({ text: 'New item' });