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

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.

主站蜘蛛池模板: 来安县| 英山县| 淮阳县| 榆林市| 广南县| 京山县| 遂川县| 通渭县| 蕉岭县| 凌海市| 镇安县| 龙口市| 仁布县| 逊克县| 罗江县| 富锦市| 博罗县| 九寨沟县| 阿拉善盟| 江永县| 深水埗区| 成武县| 肃南| 富阳市| 广南县| 衡阳县| 南宁市| 千阳县| 子洲县| 永川市| 阜城县| 姚安县| 轮台县| 札达县| 赤水市| 千阳县| 来宾市| 南阳市| 洪泽县| 达日县| 赤峰市|