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

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
}
主站蜘蛛池模板: 陆川县| 凤冈县| 蕲春县| 鄂尔多斯市| 龙门县| 久治县| 彰化市| 芒康县| 班戈县| 始兴县| 乐至县| 九江县| 尚志市| 桑日县| 康保县| 喜德县| 三门县| 浏阳市| 宿迁市| 苗栗县| 诸城市| 成安县| 齐河县| 饶河县| 镇平县| 河间市| 进贤县| 清丰县| 山阳县| 高碑店市| 红河县| 固原市| 黔西县| 千阳县| 泾阳县| 大方县| 开阳县| 雷州市| 安顺市| 桂阳县| 璧山县|