未发现错误:值为a
Error not found: value a
我已经定义了一个变量
@(mapCollectionCount: Map[String, String]) //values coming from controller
@{var a=0}
<script type="text/javascript">
var r=@mapCollectionCount.get("receipts");
r=r.toLocaleString();
</script>
<div> @a<div> //gives me error not found: value a
你的代码不工作的原因是,虽然var a
是在一个块中定义的,但在你实际使用a
之前,这个作用域就结束了。
使用defining
:
@(mapCollectionCount: Map[String, String]) //values coming from controller
@defining(0) { a =>
<script type="text/javascript">
var r=@mapCollectionCount.get("receipts");
r=r.toLocaleString();
</script>
<div> @a<div> //shouldn't give error
}
也检查这个答案:
在Play2 scala模板中声明变量
相关文章:
- 如何在angularJS中编辑时,如果DB中的值为true,则设置复选框,如果值为false,则取消选中复选框
- 如果值为空,如何设置输入的默认值?jQuery
- 在php中提交数据时,如果某些值为null,而某些值为非null,如何进行查询
- ASP Page_Load元素值为null
- onchange值为select的重载页面
- JavaScript 2D 数组将值设置为错误的协调
- 当我表中的值为 0 时,如何弹出错误消息
- JCrop 将所选内容的大小调整为错误的值
- 值为“错误”的字符串是某种保留字
- Javascript/HTML错误“属性”selectReason“的值为null或未定义,而不是函数对象
- 是否(!value)对所有错误值求值为True
- 如果值为空,则提交file=type(上传)错误
- angularJS避免在值为空时出现错误消息
- 如果JSON中的键值为空,则发送错误状态(AJAX、Node和Express)
- 未发现错误:值为a
- 检查表单字段值,如果值为0则显示错误消息
- 当值为初始值时,在新行末尾放置错误消息
- AngularJS上的Datepicker错误,值为
- 将值解析为错误的区域
- Microsoft JScript运行时错误:无法获取属性'radalert': object的值为空或