- 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.
推薦閱讀
- ServiceNow Application Development
- Java 開(kāi)發(fā)從入門到精通(第2版)
- Python機(jī)器學(xué)習(xí):數(shù)據(jù)分析與評(píng)分卡建模(微課版)
- Java程序員面試算法寶典
- 從0到1:Python數(shù)據(jù)分析
- 青少年學(xué)Python(第1冊(cè))
- Learning Vaadin 7(Second Edition)
- Unity 2017 Mobile Game Development
- C語(yǔ)言程序設(shè)計(jì)
- Mastering Business Intelligence with MicroStrategy
- 基于ARM Cortex-M4F內(nèi)核的MSP432 MCU開(kāi)發(fā)實(shí)踐
- Android開(kāi)發(fā)三劍客:UML、模式與測(cè)試
- Go語(yǔ)言開(kāi)發(fā)實(shí)戰(zhàn)(慕課版)
- CRYENGINE Game Development Blueprints
- 從程序員角度學(xué)習(xí)數(shù)據(jù)庫(kù)技術(shù)(藍(lán)橋杯軟件大賽培訓(xùn)教材-Java方向)