vuejs
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
List Rendering 40<br />
Eventually, for the sake of ordering the array in descending order, our code will look like this:<br />
1 <br />
2 <br />
5 {{ story.writer }} said "{{ story.plot }}"<br />
6 and upvoted {{ story.upvotes }} times.<br />
7 <br />
8 <br />
We can easily change the order we sort the array, by dynamically changing the order parameter. A<br />
button is added, which will toggle the value of a new variable between -1 and 1, and then the new<br />
variable is passed as order parameter to orderBy filter. Watch now.<br />
1 new Vue({<br />
2 el: '.container',<br />
3 data: {<br />
4 order: -1,<br />
5 stories: [<br />
6 {<br />
7 plot: "I crashed my car today!",<br />
8 writer: "Alex",<br />
9 upvotes: 28<br />
10 },<br />
11 {<br />
12 plot: "Yesterday, someone stole my bag!",<br />
13 writer: "John",<br />
14 upvotes: 8<br />
15 },<br />
16 {<br />
17 plot: "Someone ate my chocolate...",<br />
18 writer: "John",<br />
19 upvotes: 51<br />
20 },<br />
21 {<br />
22 plot: "I ate someone's chocolate!",<br />
23 writer: "Alex",<br />
24 upvotes: 74<br />
25 },<br />
26 ]<br />
27 }<br />
28 })