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

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.

主站蜘蛛池模板: 馆陶县| 健康| 吉林省| 泰和县| 西青区| 山阴县| 潼南县| 托克托县| 田林县| 三河市| 赣州市| 甘泉县| 安吉县| 武胜县| 山阳县| 榆社县| 铜鼓县| 舞钢市| 确山县| 岳阳市| 左权县| 建平县| 安泽县| 象山县| 阿鲁科尔沁旗| 驻马店市| 江陵县| 滁州市| 佳木斯市| 徐汇区| 洮南市| 苏尼特右旗| 秦皇岛市| 宁夏| 沙河市| 旺苍县| 益阳市| 台安县| 绥宁县| 长宁区| 易门县|