我有模板,中继器:
其中打印结果:
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