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

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>
主站蜘蛛池模板: 那曲县| 中山市| 中阳县| 青神县| 崇明县| 临颍县| 汝州市| 延庆县| 大足县| 涡阳县| 错那县| 会同县| 元朗区| 青铜峡市| 杨浦区| 乐平市| 聂荣县| 黔南| 新建县| 博爱县| 广水市| 宽城| 微博| 集贤县| 桐城市| 饶平县| 郸城县| 日土县| 聂拉木县| 定边县| 抚州市| 陆河县| 珠海市| 江门市| 安福县| 绥芬河市| 大余县| 吕梁市| 高阳县| 苗栗市| 绥阳县|