vuejs
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Components 74<br />
43 plot: 'The dark side of the Force is stronger.',<br />
44 writer: 'Darth Vader',<br />
45 },<br />
46 {<br />
47 plot: 'One does not simply walk into Mordor',<br />
48 writer: 'Boromir',<br />
49 },<br />
50 ]<br />
51 }<br />
52 })<br />
53 <br />
54 <br />
The next step is to give the user a way to vote once, the story he desires to. To apply this limit (1<br />
vote per story) we will display the ‘Upvote’ button only if user has not already voted. So, every story<br />
must have a voted property that becomes true when upvote function executes.<br />
1 <br />
2 <br />
3 {{ story.writer }} said "{{ story.plot }}".<br />
4 Story upvotes {{ story.upvotes }}.<br />
5 <br />
8 Upvote<br />
9 <br />
10 <br />
11 <br />
1 Vue.component('story', {<br />
2 template: "#story-template",<br />
3 props: ['story'],<br />
4 methods:{<br />
5 upvote: function(){<br />
6 this.story.upvotes += 1;<br />
7 this.story.voted = true;<br />
8 },<br />
9 }<br />
10 });<br />
11<br />
12 new Vue({