08.02.2017 Views

vuejs

Create successful ePaper yourself

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

Components 64<br />

1 <br />

2 <br />

3 <br />

5 Hello Vue<br />

6 <br />

7 <br />

8 <br />

9 <br />

10 <br />

11 <br />

12 <br />

13 <br />

14 Vue.component('story', {<br />

15 template: 'My horse is amazing!'<br />

16 });<br />

17<br />

18 new Vue({<br />

19 el: '.container'<br />

20 })<br />

21 <br />

22 <br />

Note<br />

Note here that you can give your custom component any name you want, but it is generally<br />

recommended that you should use a unique name to avoid having collisions with actual<br />

tags that might get introduced at some point in the future, and saving you time from having<br />

to change large amounts of code.<br />

As we mentioned at the beginning of the chapter, components are reusable which means you can<br />

append as many elements as you want. The following HTML snippet will display our story<br />

3 times.

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

Saved successfully!

Ooh no, something went wrong!