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

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
}
主站蜘蛛池模板: 民乐县| 普安县| 香格里拉县| 洪湖市| 茌平县| 龙井市| 成安县| 达孜县| 博客| 宾阳县| 河北省| 武隆县| 克东县| 宁远县| 闽侯县| 台东市| 蛟河市| 福安市| 射洪县| 阜新| 九江市| 雷山县| 延长县| 衡水市| 新昌县| 楚雄市| 阿鲁科尔沁旗| 长垣县| 治多县| 依兰县| 承德县| 无为县| 浠水县| 蒙山县| 博罗县| 鄂州市| 柘荣县| 贺兰县| 四会市| 延寿县| 尼玛县|