数据双向绑定在深层次的数组里 {#list} 中不起作用
Closed this issue · 1 comments
AndyRightNow commented
<div>
<ul>
{#list some[deeply][nested][array] as value}
<input type="text" r-model={value}>
{/list}
</ul>
</div>
这时候的value
会被绑定到 data.value
而不是 some[deeply][nested][array][value_index]
上。
然而如果我用这样:
<div>
<ul>
{#list some[deeply][nested][array] as value}
<input type="text" r-model={some[deeply][nested][array][value_index]}>
{/list}
</ul>
</div>
我猜他们应该用的是同一个 Foo
object 来存 value
和 value_index
,所以如果有4个 input 框,你在第一个 input 输入 "aaaa" 的话就会变成这样:
input: a
input: a
input: a
input: a
而不是
input: aaaa
input:
input:
input:
补充:目前的临时的hack来解决是绑到一个object里的value上,如:
<div>
<ul>
{#list some[deeply][nested][array] as obj}
<input type="text" r-model={obj.value}>
{/list}
</ul>
</div>
leeluolee commented
双向绑定 列表里 ,最好弄个对象 作为载体. 因为 regular列表循环和Angular不一样 其实不会产生一个新的子scope, 你的这个value 实际上还是属于循环外的context.
主要问题是发生在 双向绑定的 set 的时候。 是feature不是bug, 补充的处理是对的