我如何知道Webjar的内容? [英] How can I tell the contents of a webjar?

查看:113
本文介绍了我如何知道Webjar的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比方说,我想在我的Play Framework 2.3项目中使用webjar react-0.12.2,并且我一直像这样依赖它:

Let's say I want to use the webjar react-0.12.2 in my Play Framework 2.3 project, and I've depended on it like so:

libraryDependencies ++= Seq(
  "org.webjars" %% "webjars-play" % "2.3.0-2",
  "org.webjars" % "react" % "0.12.2"
)

如何确定react webjar中可用的资产?

How do I tell which assets are available in the react webjar?

如果我尝试仅访问"react.js",如以下示例所示,由于对react.js有多个匹配项,我将收到错误消息:

If I try to access simply "react.js", like in the following example, I get an error due to there being multiple matches for react.js:

<script type='text/javascript' src='@routes.WebJarAssets.at(WebJarAssets.locate("react.js"))'>

推荐答案

查看WebJars内容的最简单方法是 http ://www.webjars.org

The easiest way to see the contents of WebJars is on http://www.webjars.org

您可以看到,实际上WebJar中有两个react.js实例.因此,如果要使用定位器,则需要更详细地说明路径.但是在这种情况下,我建议您使用自动提取WebJar内容的Play资产管道.关于此的文档: https://www.playframework.com/documentation/2.3.x/Assets

You can see that there are in fact two instances of react.js in the WebJar. So if you want to use the locator you need to be more specific about the path. But in this case I'd recommend you use the Play asset pipeline that auto-extracts WebJar contents. Docs on that: https://www.playframework.com/documentation/2.3.x/Assets

因此您的代码应为:

<script type='text/javascript' src='@routes.Assets.at("lib/react/react.js")'>

这篇关于我如何知道Webjar的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆