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

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>
主站蜘蛛池模板: 永修县| 辰溪县| 登封市| 平南县| 临邑县| 苍溪县| 天气| 罗甸县| 内丘县| 平果县| 美姑县| 台湾省| 平凉市| 赤城县| 微山县| 兴海县| 从江县| 股票| 达孜县| 杨浦区| 得荣县| 汉沽区| 佛学| 察雅县| 始兴县| 时尚| 姚安县| 黑山县| 甘德县| 曲沃县| 武夷山市| 定州市| 扎赉特旗| 蕉岭县| 弋阳县| 永嘉县| 顺昌县| 贞丰县| 手游| 特克斯县| 海南省|