React.js中的类使功能混淆
您能说出以下代码有什么问题(我的眼睛被伤了)吗?
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,我将您的代码放在其中 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)