vuejs
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Working with real data 100<br />
1 <br />
2 <br />
3 Let's hear some stories!<br />
4 <br />
5 <br />
6 <br />
7 <br />
8 {{ $data | json }}<br />
9 <br />
10 <br />
11 <br />
12 <br />
13 {{ story.writer }} said "{{ story.plot }}"<br />
14 {{story.upvotes}}<br />
15 <br />
16 <br />
1 <br />
2 <br />
3 <br />
4 Vue.component('story', {<br />
5 template: "#template-story-raw",<br />
6 props: ['story'],<br />
7 });<br />
8<br />
9 var vm = new Vue({<br />
10 el: '#app',<br />
11 data: {<br />
12 stories: []<br />
13 },<br />
14 ready : function(){<br />
15 $.get('/api/stories', function(data){<br />
16 vm.stories = data;<br />
17 })<br />
18 }<br />
19 })<br />
20 <br />
We start by pulling in the jQuery from the cdnjs³. Then use the ready function and inside it,<br />
perform the GET request. After the request is successfully finished we set the response data (inside<br />
the callback) to stories array.<br />
³https://cdnjs.com/libraries/jquery/