【问题标题】:VueJS refresh content after database operation数据库操作后VueJS刷新内容
【发布时间】:2019-04-28 12:03:18
【问题描述】:

我正在使用 v-data-table 组件来显示来自 firestore 数据库的数据。它看起来像这样:

批准/拒绝功能运行良好,使用以下代码更新 firestore 数据库:

database
      .collection(member)
      .doc(userId)
      .update({
        approved: status
      })
      .then({
        console.log("School member details updated successfully")
          return this.teachers.filter(teacher => {
            return teacher.id != userId;
          });
      })
      .catch(err => {
        console.log(
          "An error occured trying to update the school member details:",
          err
        );
      });

但是,在 firestore 数据库上成功更新内容后,我不再想显示列表项,我认为像在 then() 代码块中所做的那样过滤数组会起作用,但事实并非如此。

如何在不重新加载整个页面的情况下为客户端刷新数据?

【问题讨论】:

  • Array.filter 不在位。你必须重新分配。

标签: javascript vue.js google-cloud-firestore vuetify.js


【解决方案1】:

您提到您不想在成功批准后显示特定列表项。正如您使用的teacher.id != userId。你用过teacher.id !== userId吗?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-20
    • 1970-01-01
    • 2022-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-28
    相关资源
    最近更新 更多