节点 Js Firestore 访问带有空格的数据库值



节点 Js 的新内容,期望这很容易!

在节点JS中使用Firestore,我想访问"显示名称":詹姆斯,"年龄":22

年龄没有空间,所以我可以把

const newValue = doc.data();
const age = newValue.Age;

但显示名称包含空格 你怎么打这个?

const displayName = newValue.displayName;

您需要使用[]表示法才能访问该属性。

所以:

const displayName = newValue["display name"];

相关内容

最新更新