我有模板,中繼器:
其中打印結果:
0 - 0
0 - 1
1 - 0
1 - 1
如果我使用自定義元素child-item
用相同的模板:
<template>
<p>${ $parent.$index } - ${ $index }</p>
</template>
並使用child-item
寫我的原始示例:
<template repeat.for="i of 2">
<child-item repeat.for="j of 2"></child-item>
</template>
結果只有:
-
-
-
-
有沒有辦法傳播$家長和$指數透明的child-item
?
UPDATE
後嘗試一些建議,最近我來到的是:
<template repeat.for="i of 2">
<child-item repeat.for="j of 2" parent-index.bind="$parent.$index" index.bind="$index"></child-item>
</template>
凡child-item
模板的樣子:
<template bindable="parentIndex, index">
<p>${ parentIndex } - ${ index }</p>
</template>
綁定$parent
情況下直接與parent.bind="$parent"
不工作。父索引必須直接綁定。通過這種方法,任何與$parent.$parent.$index
內聯的內容都無法實現。
:
兒童item.html
模板,中繼器舉個簡單的例子? 'index.bind =「$ index」'似乎合乎邏輯,但當前綁定上下文的值應該是多少? 'parent.bind = 「...」'? – Nenad