25.06.2018 Views

Full-Stack Vue.js 2 and Laravel 5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

List rendering<br />

The v-for directive requires a special type of expression in the form of item in<br />

items, where items is the source array, <strong>and</strong> item is an alias for the current array<br />

element being looped over.<br />

Let's work on the amenities array first. Each member of this array is an object<br />

with a title <strong>and</strong> icon property, that is: { title: 'something', icon: 'something' }<br />

We'll add the v-for directive into the template <strong>and</strong> the expression we assign to it<br />

will be amenity in amenities. The alias part of the expression, that is amenity, will<br />

refer, throughout the loop sequence, to each object in the array, starting with the<br />

first.<br />

index.html: ... ... <br />

{{ amenity.title }} <br />

It will render as: ... <br />

... Wireless Internet<br />

Pets Allowed TV Kitchen<br />

Breakfast Laptop friendly workspace

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!