每个动态键控?

Dynamic Keyed Each?

能否keyed each blocks使用组件的值属性有一个动态键?

例如:

{{#each items as item @{componentPropertyExpression}}}
    <div>{{item.stuff}}</div>
{{/each}}

目前没有——不过有一个讨论:https://github.com/sveltejs/svelte/issues/703

以防有人遇到这个问题,自 Svelte v2.4.0(2018 年 4 月)起,您可以为每个块设置动态表达式:

{#each list as item (item.id)}
  <li>{item.name}</li>
{/each}

查看官方教程:https://svelte.dev/tutorial/keyed-each-blocks

如果您通过视频学习得更好,请观看 https://youtu.be/kN4R29zbh7g and https://youtu.be/itcf8S8Az74