首页 文章

Angular2无法使用prototype.js

提问于
浏览
2

我试图在使用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

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

提前致谢!

1 回答

  • 2

    转到 prototype.js 的文件 .

    var bindTemp = Function.prototype.bind;

    在文件的开头 .

    Function.prototype.bind = bindTemp;

    在文件的末尾 . 它现在应该工作 .

    积分:Solution

相关问题