【发布时间】:2015-06-12 19:15:54
【问题描述】:
这个问题建立在我发现的一个案例 here
index.scala.html
@(text: String)(implicit messages: Messages)
@main("Fancy title") {
<h1>@messages("header.index")</h1>
<div>@text</div>
}
main.scala.html
@(title: String)(content: Html)(implicit messages: Messages)
<html>
<head>
<title>@title</title>
</head>
<body>
<h1>@messages("header.main")</h1>
@content
<body>
</html>
在此示例中,我有 index 调用 main,我希望两者都访问 messages。
编译器在 index 内给了我“could not find implicit value for parameter messages: play.api.i18n.Messages”,但如果我删除了隐式参数声明从 main 然后 index 工作正常并收到消息。似乎编译器告诉我它不知道如何将隐式参数向下传递。
在尝试解决方法之前,我想了解为什么这不起作用。
【问题讨论】: