0
我的目標是這樣的:超出最大調用堆棧大小。遞歸標籤
<app>
<child opts="{ json }"></child>
<script>
this.json = [
{
text: 'parent',
child: [
{
text: 'child1',
child: {
text: 'child2'
}
}
]
}
];
</script>
</app>
每個孩子都可以擁有自己的孩子。所以我需要在這裏遞歸標籤。這是我有:
<child>
<h1>child: { opts.opts.text }</h1>
<div if={opts.opts.child}>
<child opts={opts.opts.child}></child>
</div>
</child>
我得到Maximum call stack size exceeded
。我在閱讀中認識到,js遞歸標籤是一個問題,但沒有找到任何解決方案,或者它不能。
你能添加代碼爲'小孩'標籤?或者,如果是這樣,那就說明你是如何使用它的。 – Heikki
現在就是這樣。我想在這裏使用遞歸,因爲我不知道我會有多少嵌套的孩子。 – Michal
我不得不猜測,因爲你的例子不完整。這是你有什麼? - > http://plnkr.co/edit/07au1eYZOSjU1vldColC?p=preview – Heikki