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

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>
主站蜘蛛池模板: 贵阳市| 桑日县| 萍乡市| 游戏| 河池市| 麻栗坡县| 渝中区| 江城| 故城县| 皮山县| 汽车| 秦皇岛市| 新闻| 都匀市| 赫章县| 高青县| 兴隆县| 绵阳市| 即墨市| 林口县| 平罗县| 方山县| 丰城市| 广宗县| 天峻县| 武平县| 靖远县| 宝丰县| 台湾省| 浦城县| 会理县| 滦平县| 伊春市| 上虞市| 汕头市| 会东县| 新沂市| 云梦县| 色达县| 堆龙德庆县| 阳谷县|