在Vue文档中有一些示例,其中在:key=
循环中定义键时使用key关键字同时使用v-bind:key=
和v-for
。一个只是另一个的语法糖,还是它们做不同的事情?
Examples from the docs using both types:
:key
<my-component v-for="item in items" :key="item.id"></my-component>
v-bind:key
<my-component
v-for="(item, index) in items"
v-bind:item="item"
v-bind:index="index"
v-bind:key="item.id"
></my-component>