Angular2无法使用prototype.js

时间:2017-02-16 23:03:44

标签: angular prototypejs

我正在尝试在使用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>
&#13;
&#13;
&#13;

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

  

错误:(SystemJS)超出最大调用堆栈大小RangeError:Maximum   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 个答案:

答案 0 :(得分:2)

转到{ "_shard": "[keywords_words][4]", "_node": "QQC692ZKQIif-_2eo_wO6Q", "_index": "keywords_words", "_type": "topic_words", "_id": "133", "_score": 407.61816, "_source": {}, "_explanation": { "value": 407.61816, "description": "sum of:", "details": [ { "value": 407.61816, "description": "weight(words:baby in 0) [PerFieldSimilarity], result of:", "details": [ { "value": 407.61816, "description": "score(doc=0,freq=1000.0), product of:", "details": [ { "value": 3.5902672, "description": "queryWeight, product of:", "details": [ { "value": 3.5902672, "description": "idf, computed as log((docCount+1)/(docFreq+1)) + 1 from:", "details": [ { "value": 2, "description": "docFreq", "details": [] }, { "value": 39, "description": "docCount", "details": [] } ] }, { "value": 1, "description": "queryNorm", "details": [] } ] }, { "value": 113.53422, "description": "fieldWeight in 0, product of:", "details": [ { "value": 31.622776, "description": "tf(freq=1000.0), with freq of:", "details": [ { "value": 1000, "description": "termFreq=1000.0", "details": [] } ] }, { "value": 3.5902672, "description": "idf, computed as log((docCount+1)/(docFreq+1)) + 1 from:", "details": [ { "value": 2, "description": "docFreq", "details": [] }, { "value": 39, "description": "docCount", "details": [] } ] }, { "value": 1, "description": "fieldNorm(doc=0)", "details": [] } ] } ] } ] } ] } }, { "_shard": "[keywords_words][1]", "_node": "QQC692ZKQIif-_2eo_wO6Q", "_index": "keywords_words", "_type": "topic_words", "_id": "490", "_score": 344.91177, "_source": {}, "_explanation": { "value": 344.9118, "description": "sum of:", "details": [ { "value": 344.9118, "description": "weight(words:fashion in 2) [PerFieldSimilarity], result of:", "details": [ { "value": 344.9118, "description": "score(doc=2,freq=1000.0), product of:", "details": [ { "value": 3.3025851, "description": "queryWeight, product of:", "details": [ { "value": 3.3025851, "description": "idf, computed as log((docCount+1)/(docFreq+1)) + 1 from:", "details": [ { "value": 2, "description": "docFreq", "details": [] }, { "value": 29, "description": "docCount", "details": [] } ] }, { "value": 1, "description": "queryNorm", "details": [] } ] }, { "value": 104.43691, "description": "fieldWeight in 2, product of:", "details": [ { "value": 31.622776, "description": "tf(freq=1000.0), with freq of:", "details": [ { "value": 1000, "description": "termFreq=1000.0", "details": [] } ] }, { "value": 3.3025851, "description": "idf, computed as log((docCount+1)/(docFreq+1)) + 1 from:", "details": [ { "value": 2, "description": "docFreq", "details": [] }, { "value": 29, "description": "docCount", "details": [] } ] }, { "value": 1, "description": "fieldNorm(doc=2)", "details": [] } ] } ] } ] } ] } } 的文件。

添加

prototype.js

在文件的开头。

添加

var bindTemp = Function.prototype.bind;

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

致谢:Solution