简体   繁体   English

aptana中的JavaScript错误

[英]JavaScript error in aptana

Aptana is showing error at this line: Aptana在此行显示错误:

var myVar = myVar1 = myVar2;

although when I deploy this script it works fine in FF or IE. 尽管当我部署此脚本时,它在FF或IE中都能正常工作。

EDIT : it is showing an error on the second = sign, it is expecting a; 编辑 :它显示第二个=符号上的错误,它期望a; instead got = sign. 取而代之的是=符号。

That looks like an error coming from the JSLint JavaScript Validator. 看起来像是来自JSLint JavaScript验证程序的错误。 It's most likely complaining because myVar1 is not being declared with "var". 最有可能抱怨的原因是myVar1没有用“ var”声明。 You have a couple of options: 你有几个选择:

  1. Under Preferences->Aptana->Validation you can select "JavaScript" and turn off JSLint JavaScript Validator. 在Preferences-> Aptana-> Validation下,您可以选择“ JavaScript”并关闭JSLint JavaScript Validator。 There is a Mozilla JavaScript Validator that isn't as strict. 有一个不那么严格的Mozilla JavaScript验证程序。
  2. Add a filter on that same pref page to effectively ignore that type of error. 在相同的首选项页面上添加过滤器,以有效地忽略该类型的错误。 I think you only need a substring from the error message like "was not declared correctly", for example 我认为您仅需要错误消息中的子字符串,例如“未正确声明”
  3. You can define separate var declarations as below: 您可以如下定义单独的var声明:

Samples: 样品:

// version 1
var myVar = myVar2,
    myVar1 = myVar2;

or 要么

// version 2
var myVar = myVar2;
var myVar1 = myVar2;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM