语法错误:意外标记“-”

发布于 2024-12-27 23:58:44 字数 703 浏览 2 评论 0原文

我正在做一个 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 技术交流群。

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

发布评论

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

评论(4

π浅易 2025-01-03 23:58:44

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.

暗藏城府 2025-01-03 23:58:44

JavaScript 函数名称中不能使用连字符:

function www_ebest_eu_company_node_service_task-slot-info () {

// Should proabbly be
function www_ebest_eu_company_node_service_task_slot_info () {
//---------------------------------------------^^^^^^^^

You cannot use hyphens in JavaScript function names:

function www_ebest_eu_company_node_service_task-slot-info () {

// Should proabbly be
function www_ebest_eu_company_node_service_task_slot_info () {
//---------------------------------------------^^^^^^^^
樱娆 2025-01-03 23:58:44

连字符“-”不是命名变量或函数的有效字符。连字符用于算术、减法,而不是用于命名变量。您可以用下划线替换连字符或使用 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.

—━☆沉默づ 2025-01-03 23:58:44

标识符(函数、变量等)名称中不允许使用破折号。与下划线或驼峰命名法保持一致。

Dashes are not allowed in identifier (function, variables, etc) names. Stay consistant with underscores or camelCase.

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