使标识符或关键字跟随数字标识符反应-快速API

发布于 2025-01-10 08:07:16 字数 340 浏览 1 评论 0原文

我尝试使用 Rapid api 中的 coinranking api,但当 ai 显示加密货币的 24 小时交易量时出现错误。

数据显示如下:

  Object
    data:
     coin:
      24hVolume: "21504479215"
     allTimeHigh: {price: '68763.41083248306', timestamp: 1636502400}

但是当我输入 cryptoDetails?.coin.24hVolume 时,

我收到一条错误消息:标识符或关键字不遵循数字标识符。

我怎样才能覆盖这个?

I try to use the coinranking api from rapid api but i get a error when a i went to display the 24h volume of a cryptocurrency.

the data is display like this:

  Object
    data:
     coin:
      24hVolume: "21504479215"
     allTimeHigh: {price: '68763.41083248306', timestamp: 1636502400}

but when i type cryptoDetails?.coin.24hVolume

I got a error that say: An identifier or keyword does not follow a numeric identifier.

How i can override this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

再浓的妆也掩不了殇 2025-01-17 08:07:16

JavaScript 中不允许使用数字标识符。但是,您可以使用 Bracket 访问对象属性符号

在 object[property_name] 语法中,property_name 只是一个字符串或符号。因此,它可以是任何字符串,包括 '1foo'、'!bar!',甚至是 ' '(空格)。

像这样。

obj.data.coin['24hVolume']

Numeric identifiers are not allowed in JavaScript. However, you could access to object properties using Bracket Notation.

In the object[property_name] syntax, the property_name is just a string or Symbol. So, it can be any string, including '1foo', '!bar!', or even ' ' (a space).

Like this.

obj.data.coin['24hVolume']
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文