This is the final article from the short Vue and Firestore series. In this article, we will delete the entries from our Firestore database.
这是简短的Vue和Firestore系列的最后一篇文章。 在本文中,我们将从Firestore数据库中删除条目。
介绍 (Introduction)
We have created our app, created a database, configured that database to run in the app, sent our notes to the database, and also fetched notes from the database.
我们已经创建了应用程序,创建了数据库,配置了该数据库以在应用程序中运行,将注释发送到数据库,还从数据库中获取了注释。
We can create new notes which are stored in a database so we don’t lose our notes when we refresh the page. But we don’t have a way to delete any notes. Let’s make that happen.
我们可以创建存储在数据库中的新笔记,因此刷新页面时不会丢失笔记。 但是我们没有办法删除任何笔记。 让我们做到这一点。
添加按钮以删除笔记 (Adding a button to delete notes)
We will add a button beside each note. Clicking that button will run a method that will remove the note from our notes
array and will then delete that note from the database.
我们将在每个音符旁边添加一个按钮。 单击该按钮将运行一种方法,该方法将从notes
数组中删除便笺,然后从数据库中删除该便笺。
We have to remove it from the notes
array as well as the database since even though it's removed from the database, it will still show on our screen until we refresh the page. Only after we refresh the page, will the array be populated with the notes in the database and reflect our changes.
我们必须将其从notes
数组以及数据库中删除,因为即使将其从数据库中删除,它仍然会显示在屏幕上,直到刷新页面为止。 只有刷新页面后,阵列中的注释才会填充到数据库中,并反映出我们的更改。
So removing it from the array will make su