(播放框架 2.4) 在客户端反向路由图像?

(Play framework 2.4) reverse routing images in client side?

你会怎么做

@routes.Assets.versioned("images/....")

在客户端?

谢谢。

如文档中所述,您需要为此使用 Javascript router

它可以在 dedicated action, but you can also insert it directly into your template as Embedded router 内声明它就像:

一样简单
<head>
    ...

    @helper.javascriptRouter("jsRoutes")(
        routes.javascript.Assets.versioned
    )

    <script>
        console.log(jsRoutes.controllers.Assets.versioned("images/favicon.png" ).url);
    </script>

</head>