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

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
}
主站蜘蛛池模板: 商城县| 荆门市| 枣庄市| 永顺县| 甘肃省| 阿坝县| 黑山县| 蓝田县| 浦北县| 刚察县| 镇平县| 菏泽市| 绍兴市| 宾川县| 葵青区| 神池县| 蓬溪县| 鄯善县| 津南区| 离岛区| 黎城县| 贵南县| 德昌县| 武穴市| 兴安县| 扬州市| 靖宇县| 和林格尔县| 鄂尔多斯市| 舞钢市| 濮阳市| 扎赉特旗| 翁牛特旗| 新田县| 安徽省| 荣成市| 牟定县| 和田县| 离岛区| 宝应县| 清水河县|