官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 拉萨市| 长武县| 三江| 泽库县| 永德县| 永胜县| 南江县| 怀集县| 莆田市| 威信县| 中江县| 利辛县| 剑川县| 阿克苏市| 宜春市| 龙井市| 和政县| 炎陵县| 吉木萨尔县| 怀远县| 思南县| 平乡县| 宜城市| 青州市| 剑河县| 苏尼特左旗| 江达县| 乌鲁木齐市| 财经| 双辽市| 循化| 寿宁县| 顺义区| 清河县| 乐业县| 府谷县| 阿克陶县| 灵台县| 垣曲县| 苗栗市| 特克斯县|