在 View 文件中添加反向路由导致错误。以下是片段:
@main(title = "index") {
<head>
<link rel="stylesheet" type="text/css" href='@routes.Assets.at("/Content/Site.css")' />
<script type="text/javascript" src='@routes.Assets.at("Scripts/bootstrap.js")'></script>
</head>
<body>
</body>
}
我已经在公共(public)文件夹中添加了 css 和 js 文件
[error] C:\myproject\app\views\index.scala.html:5: value at is not a member of controllers.ReverseAssets
[error] <link rel="stylesheet" type="text/css" href='@routes.Assets.at("/Content/Site.css")' />
[error] ^
[error] C:\myproject\app\views\index1.scala.html:6: value at is not a member of controllers.ReverseAssets
[error] <script type="text/javascript" src='@routes.Assets.at("Scripts/bootstrap.js")'></script>
感谢任何帮助。
最佳答案
我必须使用以下语法来消除错误
<link rel="stylesheet" type="text/css" href='@routes.Assets.versioned("stylesheets/Content/bootstrap.css")'
关于javascript - 基于play框架的应用在 View 中添加css和js文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44940477/