@(message: String)(exchangelist: java.util.ArrayList[String])(implicit session: play.mvc.Http.Session)
@main(title = message)(session) {
<head>
...
</head>
<body>
<script>
startup(exchangelist);
<script>
</body>
这样的代码,如何传递参数&#34; exchangelist&#34;到Js功能&#34; startup()&#34;?这种方法不起作用。
答案 0 :(得分:0)
我建议尝试元标记:
<html>
<head>
<!-- <meta name="exchangelist" content='@{exchangelist.mkstring(",")}'> -->
<meta name="exchangelist" content='yellow,black,green'>
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
</head>
<script>
function startup(list) {
alert("startup called with " + list);
}
var el = $('meta[name=exchangelist]').attr("content").split(",");
startup(el);
</script>
</html>
&#13;