React.js中的类使功能混淆

发布于 2025-02-13 07:17:01 字数 139 浏览 0 评论 0原文

您能说出以下代码有什么问题(我的眼睛被伤了)吗?

class Numbers extends React.Component {
  const arrayOfNumbers = _.range(1, 10);
}

Can you tell what’s wrong with the following code (my eyes are broken)?

class Numbers extends React.Component {
  const arrayOfNumbers = _.range(1, 10);
}

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

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

发布评论

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

评论(1

十二 2025-02-20 07:17:01

因此,我将您的代码放在其中 https://www.typescriptlang.org

它说类成员不能具有“ const”关键字。

我认为代码的问题是您尝试通过添加const来使类成员变常量。关键词。

但是类成员不能具有'const'关键字。(链接使用

So I put your code in there https://www.typescriptlang.org
And it says A class member cannot have the 'const' keyword.

I think that the issue with your code is that you try to make a class member constant by adding the const keyword.

But a class member cannot have the 'const' keyword. (link found with this amazing tool)

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