function calcTotalScore(){
var arr = ["A","B","C","D","E","F"];
$.each(arr, function(n,val){
calcTotal(val);
});
}
calcTotal(value){
// sample code
}
我在速度模板语言(VTL)中使用上述函数calcTotalScore()
,但它说:
Encountered "," Was expecting one of:
<EOF>
"(" ...
<RPAREN> ...
<ESCAPE_DIRECTIVE> ...
<SET_DIRECTIVE> ...
"##" ...
"\\\\" ...
"\\" ...
<TEXT> ...
"*#" ...
"*#" ...
<STRING_LITERAL> ...
<IF_DIRECTIVE> ...
<STOP_DIRECTIVE> ...
<INTEGER_LITERAL> ...
<FLOATING_POINT_LITERAL> ...
<WORD> ...
<BRACKETED_WORD> ...
<IDENTIFIER> ...
<DOT> ...
"{" ...
"}" ...
我做错了什么?
答案 0 :(得分:4)
VTL将jQuery的$
解释为变量的开头。然后它抱怨,因为变量名称不能以点开头。
您有两种选择:
\$
jQuery
代替$
答案 1 :(得分:1)
<强>更新强>
见a'r的回答:D
你只是在calcTotal前面缺少一个“函数”;)
http://fiddle.jshell.net/gabel/7SvUY/1/
function calcTotalScore(){
var arr = Array("A","B","C","D","E","F");
$.each(arr, function(n,val){
calcTotal(val);
});
}
function calcTotal(value){
// sample code
alert(value);
}
calcTotalScore();