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

List rendering

Thev-fordirective requires a special type of expression in the form ofitem in items, whereitemsis the source array, anditemis an alias for the current array element being looped over.

Let's work on theamenitiesarray first. Each member of this array is an object with atitleandiconproperty, that is:

{ title: 'something', icon: 'something' }

We'll add thev-fordirective into the template and the expression we assign to it will beamenity in amenities. The alias part of the expression, that is amenity, will refer, throughout the loop sequence, to each object in the array, starting with the first.

index.html:

<p class="container">
  <p class="heading">...</p>
  <hr>
  <p class="about">...</p>
  <p class="lists">
    <p v-for="amenity in amenities">{{ amenity.title }}</p>
  </p>
</p>

It will render as:

<p class="container">
  <p class="heading">...</p>
  <hr>
  <p class="about">...</p>
  <p class="lists">
    <p>Wireless Internet</p>
    <p>Pets Allowed</p>
    <p>TV</p>
    <p>Kitchen</p>
    <p>Breakfast</p>
    <p>Laptop friendly workspace</p>
  </p>
</p>
主站蜘蛛池模板: 柘荣县| 五峰| 房产| 青龙| 延庆县| 武威市| 罗江县| 广宁县| 宁晋县| 吴旗县| 息烽县| 绍兴县| 江川县| 汝阳县| 龙井市| 弥勒县| 景东| 长沙县| 武定县| 康保县| 岳阳市| 兴义市| 安新县| 南康市| 忻城县| 永德县| 黑河市| 莆田市| 光山县| 肥乡县| 准格尔旗| 都匀市| 深水埗区| 白山市| 黔西| 昌平区| 兴和县| 黔西县| 凤山县| 茌平县| 政和县|