Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在play framework中的.scala.html文件中执行表达式_Html_Scala_Playframework 2.0 - Fatal编程技术网

如何在play framework中的.scala.html文件中执行表达式

如何在play framework中的.scala.html文件中执行表达式,html,scala,playframework-2.0,Html,Scala,Playframework 2.0,我想问一下如何在play framework中的.scala.html文件中执行表达式。您可以通过为每个scala代码添加@符号来执行scala代码。还可以通过以下方式定义变量: @defining(0){ i => @ i } 上面的代码显示0,但我想问的是如何对变量i执行表达式。例如,我想做: @i = i + 1 每当我在中的.scala.html文件中键入此内容时,将显示: 0 = i + 1 我想要的是在表达式之后修改 谢谢。试试这个表达: @i = @{1 + 1

我想问一下如何在play framework中的.scala.html文件中执行表达式。您可以通过为每个scala代码添加@符号来执行scala代码。还可以通过以下方式定义变量:

 @defining(0){ i => 
 @ i
 }
上面的代码显示0,但我想问的是如何对变量i执行表达式。例如,我想做:

@i = i + 1
每当我在中的.scala.html文件中键入此内容时,将显示:

0 = i + 1
我想要的是在表达式之后修改

谢谢。

试试这个表达:

@i = @{1 + 1}

如果删除空格会发生什么?我认为@magic char只是告诉解释器接下来是scala语言,直到下一个分隔符(\n\t…)为止。你也可以用括号来扩展@的功能。