语法错误:意外标记“-”
我正在做一个 Web 应用程序,当我开始用 JavaScript 编写代码时,我收到此错误:
Syntax error: unexpected token "-" javascript
我正在使用 Aptana Studio 3。我认为这是 Aptana 的问题,所以然后我尝试使用 Eclipse,但仍然得到了同样的错误。 Eclipse 向我显示了这个错误:
Cannot return from outside a function or method.
这是我的函数:
function www_ebest_eu_company_node_service_task-slot-info () {
this.typeMarker = 'www_ebest_eu_company_node_service_task-slot-info';
this._endDateTime = null;
this._number = null;
this._orderId = null;
this._startDateTime = null;
this._taskId = null;
this._taskStatus = null;
}
我有很多这样的函数,对于每个函数,我都会遇到相同的错误。
有人有同样的问题吗?
I'm doing a web application, and when I started writing the code in JavaScript I'm getting this error:
Syntax error: unexpected token "-" javascript
I'm using Aptana Studio 3. I thought it was Aptana's problem, so then I tried with Eclipse, but still got the same error. Eclipse shows me this error:
Cannot return from outside a function or method.
Here's my function:
function www_ebest_eu_company_node_service_task-slot-info () {
this.typeMarker = 'www_ebest_eu_company_node_service_task-slot-info';
this._endDateTime = null;
this._number = null;
this._orderId = null;
this._startDateTime = null;
this._taskId = null;
this._taskStatus = null;
}
I have many functions like this, and for every of them I'm getting the same error.
Does anyone have the same problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
www_ebest_eu_company_node_service_task-slot-info
不是有效的 JavaScript 标识符。www_ebest_eu_company_node_service_task-slot-info
is not a valid JavaScript identifier.JavaScript 函数名称中不能使用连字符:
You cannot use hyphens in JavaScript function names:
连字符“-”不是命名变量或函数的有效字符。连字符用于算术、减法,而不是用于命名变量。您可以用下划线替换连字符或使用 CamelCase 表示法。
A hyphen "-" is not a valid character for naming variables or functions. The hyphen is used for arithmetic, subtraction, and not for naming variables. You can replace the hyphens with underscores or go with a CamelCase notation.
标识符(函数、变量等)名称中不允许使用破折号。与下划线或驼峰命名法保持一致。
Dashes are not allowed in identifier (function, variables, etc) names. Stay consistant with underscores or camelCase.