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.

Focusing now on the FeatureList component, follow these steps:<br />

1. Add items to the props array in the configuration object<br />

2. items will be array which we iterate inside the section<br />

3. In the loop, item is an alias to any particular list item. We can create a slot<br />

<strong>and</strong> bind that list item to the slot using v-bind="item". (We haven't used v-bind<br />

without an argument before, but this will bind the properties of an entire<br />

object to the element. This is useful as the amenities <strong>and</strong> prices objects have<br />

different properties <strong>and</strong> we now don't have to specify them.)<br />

resources/assets/components/FeatureList.vue: {{ title }} export<br />

default { props: ['title', 'items'] } ...<br />

Now we'll return to our view. Let's work on the amenities list first:<br />

1. Declare a template element inside the FeatureList declaration.<br />

2. The template must include the slot-scope property to which we assign an<br />

alias, amenity. This alias allows us to access the scoped props.<br />

3. Inside the template, we can use exactly the same markup we had before to<br />

display our amenity list items.<br />

resources/views/app.blade.php: <br />

<br />

@{{ amenity.title }} <br />

Here's the complete main template with prices as well.<br />

resources/views/app.blade.php: ... ... <br />

@{{ amenity.title }} @{{ price.title<br />

}}: @{{ price.value }}

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

Saved successfully!

Ooh no, something went wrong!