vuejs2 - 增量值在使用示例代码的 Firestore 中不起作用
问题描述
在 Firestore 文档的此页面上,提供的代码在我的 Vue 项目中不起作用。
https://cloud.google.com/firestore/docs/manage-data/add-data#increment_a_numeric_value
Firestore 在我的 Vue 应用程序中被广泛使用。它甚至被用在我正在尝试的同一页面上。
我正在使用 VUE CLI 3、firebase 6.0.2、firebase-admin 8.0.0、vue 2.6.10。
var washingtonRef = db.collection('cities').doc('DC');
// Atomically increment the population of the city by 50.
washingtonRef.update({
population: firebase.firestore.FieldValue.increment(50)
});
控制台中的错误消息显示“firebase”未定义。如果我取出“firebase”,它会说“firestore”没有定义。如果我取出“firestore”,它会显示“未定义 FieldValue”。
为什么它不起作用?我只想添加简单的投票。
解决方案
推荐阅读
- azure - 如何在 xlsx 文件中添加关系属性列
- javascript - TypeError:使用 defaultProps 后无法将 undefined 转换为对象
- c++ - 更改 Chromium 品牌 (MacOS)
- python - pygal 在“添加”期间更改一行的颜色
- dart - 在 VS Code 中找不到扩展设置
- java - 用于管理 SimpleDateFormat 的 CodenameOne 实现的 X、XX、XXX(ISO 时区)格式案例的 Java 代码
- python-3.x - 如何使用 websocket-client 将实时流数据保存到数据帧
- sql - 您如何编写将当前时间戳减去 30 分钟的 CASE?
- python - 使用 pandas 和 numpy 只返回有差异的行
- r - 具有生成回归器的 2SLS,第一阶段校正