【问题标题】:Angular2 not working with prototype.jsAngular2 不适用于prototype.js
【发布时间】:2017-07-06 07:10:33
【问题描述】:

我正在尝试在使用prototype.js 的现有应用程序中设置Angular2。但看起来 Angular2 也依赖于 prortotype.js(如果我错了,请纠正我),因此在尝试加载应用程序时会抛出 "maximum call stack size exceeded RangeError(in Chrome)"。我对 Angular2 还是很陌生。

我可以通过添加prototype.js 依赖项在Angular2 快速入门应用程序中重现它。

<!DOCTYPE html>
<html>
  <head>
    <title>Angular QuickStart</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <base href="/">
    <link rel="stylesheet" href="styles.css">

    <!-- Polyfill(s) for older browsers -->
    <script src="node_modules/core-js/client/shim.min.js"></script>

    <script src="node_modules/zone.js/dist/zone.js"></script>

    <script src="node_modules/systemjs/dist/system.src.js"></script>


    <script src="systemjs.config.js"></script>
    <script>
      System.import('main.js').catch(function(err){ console.error(err); });
    </script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/prototype/1.6.0.3/prototype.js"></script>
  </head>

  <body>
    <my-app>Loading AppComponent content here ...</my-app>
  </body>
</html>

Web 检查器控制台中的部分堆栈跟踪是:

错误:(SystemJS)超过最大调用堆栈大小 RangeError:最大值 ParamDecoratorFactory 超出调用堆栈大小 (http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:401:39) 在新 (https://cdnjs.cloudflare.com/ajax/libs/prototype/1.6.0.3/prototype.js:214:23) 在 ParamDecoratorFactory

我做错了什么?或者如果没有,是否有解决方法?

提前致谢!

【问题讨论】:

    标签: angular prototypejs


    【解决方案1】:

    转到prototype.js 的文件。

    添加

    var bindTemp = Function.prototype.bind;

    在文件的开头。

    添加

    Function.prototype.bind = bindTemp;

    在文件末尾。 它现在应该可以工作了。

    致谢:Solution

    【讨论】:

    • 有没有解决这个问题,但在角度方面而不是prototype.js?
    猜你喜欢
    • 2014-04-05
    • 2017-10-13
    • 2020-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-22
    • 2016-07-15
    • 1970-01-01
    相关资源
    最近更新 更多