有没有办法在scala

有没有办法在scala

本文介绍了有没有办法在scala js文件中使用Play路由?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Play!使用Scala js的Scala 2.4,我想知道是否有一种方法可以从scala js文件中获取路由配置文件.

I use Play! Scala 2.4 with scala js, and I would like to know if there is a way to get the routing config file from the scala js files.

这将非常方便,因为它可以让我用application.routes.Application.admin()之类的形式将url替换为字符串.

It would be very convenient since it would allow me to replace urls as string by something like application.routes.Application.admin().

您知道执行此操作的任何解决方法吗?

Do you know any workaround to do this?

推荐答案

您可以使用 javascript反向路由.这将帮助您从js代码中定义路由.看起来像这样:

You can use javascript reverse routing.It will help you to define routes from your js code.It will look like this:

@helper.javascriptRouter("jsRoutes")(
  routes.javascript.Application.admin
)
...
<script>
   console.log(jsRoutes.routes.Application.admin())
</script>

这篇关于有没有办法在scala js文件中使用Play路由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 17:11