25.06.2018 Views

Full-Stack Vue.js 2 and Laravel 5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Components<br />

Components extend basic HTML elements <strong>and</strong> allow you to create your own<br />

reusable custom elements.<br />

For example, here I've created a custom element, grocery-item, which renders as a<br />

li. The text child of that node is sourced from a custom HTML property, title,<br />

which is accessible from within the component code: <br />

Grocery list <br />

<br />

<strong>Vue</strong>.component( 'grocery-item', {<br />

props: [ 'title' ], template: '{{ title }}' });<br />

new <strong>Vue</strong>({ el: '#app' }); <br />

This renders as follows: Grocery list <br />

Bread Milk <br />

But probably the main reason to use components is that it makes it easier to<br />

architect a larger application. Functionality can be broken into reuseable, selfcontained<br />

components.

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

Saved successfully!

Ooh no, something went wrong!