有使用该密钥关键字使用既在Vue的文档的例子:key=和v-bind:key=限定在该键时v-for循环。一个仅仅是另一个的语法糖,还是它们做不同的事情?
:key
<my-component v-for="item in items" :key="item.id"></my-component>
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
:key=并且v-bind:key=完全一样。
资料来源:https : //vuejs.org/v2/api/#v-bind
绑定
速记:
:
| 归档时间: |
|
| 查看次数: |
109 次 |
| 最近记录: |