- Full-Stack Vue.js 2 and Laravel 5
- Anthony Gore
- 122字
- 2021-07-02 19:57:20
Key
As you might expect, the DOM nodes generated byv-for="amenity in amenities"are reactively bound to theamenitiesarray. If the content ofamenitieschanges, Vue will automatically re-render the nodes to reflect the change.
When usingv-for, it's recommended you provide a uniquekeyproperty to each item in the list. This allows Vue to target the exact DOM nodes that need to be changed, making DOM updates more efficient.
Usually, the key would be a numeric ID, for example:
<p v-for="item in items" v-bind:key="item.id"> {{ item.title }} </p>
For the amenities and prices lists, the content is not going to change over the life of the app, so there's no need for us to provide a key. Some linters may warn you about this, but in this case, the warning can be safely ignored.
推薦閱讀
- Java逍遙游記
- Learning Spring 5.0
- Learning AndEngine
- Learning Vaadin 7(Second Edition)
- Learning Laravel's Eloquent
- Visual Basic程序設(shè)計實驗指導(dǎo)(第二版)
- Solr Cookbook(Third Edition)
- Visual Basic程序設(shè)計(第三版)
- Android系統(tǒng)下Java編程詳解
- Microsoft HoloLens By Example
- INSTANT Premium Drupal Themes
- Android從入門到精通
- 前端程序員面試筆試真題與解析
- 像程序員一樣使用MySQL
- WCF 4.5 Multi-Layer Services Development with Entity Framework(Third Edition)