在 index.scala.html 中使用 JS 文件播放 Framework 2.5
Play Framework 2.5 using JS file in index.scala.html
我目前正在尝试将我的 xyz.scala.html 文件中重复的 JavaScript 代码重构到一个单独的 main.js 文件中,然后可以使用类似下面的内容链接到该文件(来自我的 scala.html 个文件):
<script src='@routes.Assets.at("javascripts/main.js")'><script>
并在我的 conf/routes 文件中使用以下内容:
GET /js/*file controllers.Assets.at(path = "/public/javascripts", file)
在 Google 上搜索后,我正在努力寻找一种简单的方法来从我的 Play Framework 应用程序中的文件中使用 JS 并设置 conf/routes 文件。
有谁知道使它起作用的简单方法吗?
Public 资产文件夹
在routes
文件中记录
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
twirl 模板中的脚本加载
<script src="@routes.Assets.versioned("javascripts/hello.js")" type="text/javascript"></script>
我目前正在尝试将我的 xyz.scala.html 文件中重复的 JavaScript 代码重构到一个单独的 main.js 文件中,然后可以使用类似下面的内容链接到该文件(来自我的 scala.html 个文件):
<script src='@routes.Assets.at("javascripts/main.js")'><script>
并在我的 conf/routes 文件中使用以下内容:
GET /js/*file controllers.Assets.at(path = "/public/javascripts", file)
在 Google 上搜索后,我正在努力寻找一种简单的方法来从我的 Play Framework 应用程序中的文件中使用 JS 并设置 conf/routes 文件。
有谁知道使它起作用的简单方法吗?
Public 资产文件夹
在routes
文件中记录
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
twirl 模板中的脚本加载
<script src="@routes.Assets.versioned("javascripts/hello.js")" type="text/javascript"></script>