【问题标题】:Using 3rd party libraries with requirejs将 3rd 方库与 requirejs 一起使用
【发布时间】:2012-09-27 06:50:55
【问题描述】:

您好,我尝试使用 requirejs 来组织我的代码,但我需要使用一个使用 google-closure-compiler 的库,该库是 box2djs,您可以从

https://github.com/leonidax/pl.git

发现代码调用了goog.require()等函数

我可以通过 RequireJS 来使用这个库吗?

【问题讨论】:

    标签: javascript box2d requirejs google-closure-compiler


    【解决方案1】:

    哦,你是在要求一堆伤害。

    闭包库和 google 依赖模型(goog.require 等)紧密相连。

    你最好到处使用闭包工具并尝试破解复合解决方案。

    【讨论】:

      【解决方案2】:

      我确实让谷歌闭包库和 RequireJS 一起工作。只要确保 Closure 的东西在 RequireJS 的东西之前。

      <script src='../externalJS/requirejs/require.js'></script>
      <script src="../externalJS/closure-library-read-only/closure/goog/base.js"></script>
      
      <script>
      
          goog.require('goog.structs');
          goog.require('goog.structs.PriorityQueue');
      
          // i just had to make sure that the closure lib stuff came before the requirejs stuff
      
          requirejs([
              'loaders_parsers/requiredLibrarys',
          ]);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-11-01
        • 1970-01-01
        • 1970-01-01
        • 2015-09-08
        • 1970-01-01
        • 2014-10-06
        • 2023-04-09
        • 2015-04-27
        相关资源
        最近更新 更多