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

Lists section

The next bit of content we'll add to our page is theAmenitiesandPriceslists:

Figure 2.7. Lists section

If you look at the mock-listing sample, you'll see that theamenitiesandpricesproperties on the object are both arrays.

sample/data.js:

var sample = {
  title: '...',
  address: '...',
  about: '...',
  amenities: [
    {
      title: 'Wireless Internet',
      icon: 'fa-wifi'
    },
    {
      title: 'Pets Allowed',
      icon: 'fa-paw'
    },
    ...
  ],
  prices: [
    {
      title: 'Per night',
      value: '$89'
    },
    {
      title: 'Extra people',
      value: 'No charge'
    },
    ...
  ]
}

Wouldn't it be easy if we could just loop over these arrays and print each item to the page? We can! This is what thev-fordirective does.

First, let's add these as data properties on our root instance.

app.js:

data: {
  ...
  amenities: sample.amenities,
  prices: sample.prices
}
主站蜘蛛池模板: 兴义市| 渭南市| 新郑市| 南通市| 滕州市| 托里县| 景泰县| 措勤县| 资中县| 湖北省| 辽阳市| 乌鲁木齐县| 屯留县| 潼关县| 定兴县| 临武县| 阿合奇县| 淅川县| 中江县| 康乐县| 石台县| 萝北县| 阜平县| 洛扎县| 新河县| 汕尾市| 永兴县| 荆州市| 绍兴县| 延边| 万山特区| 赣州市| 丰县| 巴南区| 莆田市| 蒲城县| 株洲市| 嘉荫县| 华容县| 昌宁县| 正镶白旗|