2

在我之前的 Play 应用程序中,我曾经使用 Webjars 和 RequireJS 来管理依赖项。我可以毫无问题地使用 require(['angular', 'webjars!ui-bootstrap-tpls.js'], function(angular) {...}) 。

最近我在 www.webjars.org 上更新了 webjars 和几个 webjars 相关的 deps(webjars-ui-bootstrap 等)到最新版本,我找到了 webjars!加载程序插件无法正常工作。我检查了 webjars-seed-play 应用程序并修改了一些代码,例如:

require(['angular', './controllers', './directives', './filters', './services', 'angular-route', 'webjars!ui-bootstrap-tpls.js'],
    function (angular, controllers) {

        // Declare app level module which depends on filters, and services

        angular.module('myApp', ['myApp.filters', 'myApp.services', 'myApp.directives', 'ngRoute', 'ui.bootstrap']).
            config(['$routeProvider', function ($routeProvider) {
                $routeProvider.when('/view1', {templateUrl: 'partials/partial1.html', controller: controllers.MyCtrl1});
                $routeProvider.when('/view2', {templateUrl: 'partials/partial2.html', controller: controllers.MyCtrl2});
                $routeProvider.otherwise({redirectTo: '/view1'});
            }]);

        angular.bootstrap(document, ['myApp']);

    });

它只是抱怨 ui.bootstrap 不可用,我认为应该由 webjars!ui-bootstrap-tpls.js 加载。我在这里做错了什么?请帮我。谢谢。

我在 build.sbt 中的部门:

libraryDependencies ++= Seq(
  "org.webjars" %% "webjars-play" % "2.2.1-2",
  "org.webjars" % "angularjs" % "1.2.13",
  "org.webjars" % "bootstrap" % "3.1.1",
  "org.webjars" % "requirejs" % "2.1.11-1",
  "org.webjars" % "angular-ui-bootstrap" % "0.10.0"
)  
4

1 回答 1

3

很抱歉给您带来麻烦。现在 WebJars 正式支持 RequireJS,我们必须进行一些更改:http ://www.jamesward.com/2014/02/19/official-support-for-requirejs-in-webjars

简而言之,webjars!插件加载器已被普通的 RequireJS 模块和路径配置所取代。一些 WebJars 尚未更新。因此,如果您遇到问题,请针对 WebJar 提出问题。

于 2014-03-07T16:04:15.207 回答