首页 > 解决方案 > firebase.firestore.FieldValue.arrayUnion 不是函数

问题描述

我正在尝试更新我的 Firestore 中的数组,我遵循了 Google 提供的文档(https://firebase.google.com/docs/firestore/manage-data/add-data)但它不起作用,我还检查以确保我拥有最新版本的 firebase npm 模块。

这是我的代码:

> db
                    .collection('Data')
                    .doc('One')
                    .collection('Doc')
                    .doc(this.$route.params.id.toLowerCase())
                    .update({
                        myArr: firebase.firestore.FieldValue.arrayUnion(
                           'test'
                        ),
                    })
                    .then(() => console.log('Successfully written'))
                    .catch(err => console.log(err));

标签: javascriptfirebasegoogle-cloud-firestore

解决方案


Firebase npm 模块已过时。不得不手动重新安装


推荐阅读