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

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.

主站蜘蛛池模板: 祁东县| 扎兰屯市| 淳化县| 长沙市| 昌吉市| 洪洞县| 秭归县| 平远县| 桐梓县| 白玉县| 若尔盖县| 东兰县| 金湖县| 抚顺县| 太原市| 景泰县| 三江| 萨嘎县| 会东县| 蚌埠市| 呼伦贝尔市| 浦东新区| 白朗县| 宁国市| 东宁县| 吉木乃县| 桃源县| 老河口市| 革吉县| 常州市| 那坡县| 博乐市| 铁力市| 安陆市| 邯郸县| 常德市| 江北区| 江阴市| 延寿县| 蓬莱市| 丘北县|