symfony 中的 RequireJS

RequireJS in symfony

我是 symfony2 框架的新开发人员,实际上我遇到了一些困难:我正在尝试集成一个完整的前端开源应用程序,该应用程序是使用 AngularJS 开发的(angularjs-Quizzler)。 但是当我整合这个项目时,我不知道把一些文件放在哪里。例如:我有一个 JavaScript 文件,它使用其他 JavaScript 个文件:

    head.js(

  { require    : "./vendor/requirejs/require.js",                  size: "80196"   },
  { underscore : "./vendor/underscore/underscore.js",              size: "43568"   },

  { angular    : "./vendor/angular/angular.js",                    size: "551057"  },
  { ngRoute    : "./vendor/angular-route/angular-route.js",        size: "30052"   },
  { ngSanitize : "./vendor/angular-sanitize/angular-sanitize.js",  size: "19990"   }

)

所以我在我的浏览器控制台中得到了这个:

http://localhost/RSS/web/vendor/underscore/underscore.js Failed to load resource: the server responded with a status of 404 (Not Found)

http://localhost/RSS/web/vendor/requirejs/require.js Failed to load resource: the server responded with a status of 404 (Not Found)

http://localhost/RSS/web/vendor/angular/angular.js Failed to load resource: the server responded with a status of 404 (Not Found)

http://localhost/RSS/web/vendor/angular-sanitize/angular-sanitize.js Failed to load resource: the server responded with a status of 404 (Not Found)

http://localhost/RSS/web/vendor/angular-route/angular-route.js Failed to load resource: the server responded with a status of 404 (Not Found)

我试过传闻中的 RequireJs Bundle,但使用起来似乎很复杂,可能有更软的解决方案。谢谢

尝试将它们放在 web 目录中的 js 目录中。

每次都像这样在树枝中调用它们{{asset('js/script.js')}}

例子:

{ require    : "{{asset('js/require.js')}}", size: "80196"   },

感谢您的回答,但我并没有像那样工作来获得解决方案,在紧张的一天之后,我找到了一种解决问题的方法,只需将 "main.js" 中的 URL 修改为让它可以被 symfony 理解 示例:

{ require    : "./vendor/requirejs/require.js",                  size: "80196"   }

变成

{ require    : "/MyProjectName/web/bundles/mybundle/js/vendor/requirejs/require.js",                  size: "80196"   }