-
Notifications
You must be signed in to change notification settings - Fork 3
/
example_03.html
55 lines (49 loc) · 1.77 KB
/
example_03.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<html>
<head>
<title>Vue.js Example 03</title>
<link rel="stylesheet" type="text/css" href="bootstrap-3.3.7-dist/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="styles/site.css">
<script src="lib/[email protected]"></script>
</head>
<body>
<div id="app">
<ul class="list-group">
<li class="list-group-item" v-for="book in library">{{book.title}}</li>
</ul>
</div>
<script>
/**
Sometimes we have a collection of data: Array.
In our library array we have 4 objects (books).
Each object contains a title field.
To display all the titles we need to iterate on each object in our library array.
To do that we use: v-for: (v-for="book in library")
Can be read as: for each book in library.
Each time "book" will represent the next object in our "books" Array.
Which will let us reference its fields.
*/
var app = new Vue({
el: '#app',
data: function () {
return {
library: [
{ title: 'Microwaving for one' },
{ title: 'I am almost Italian '},
{ title: '100 pastas '},
{ title: 'Silver spoon '}
]
};
}
});
</script>
</body>
</html>
<!--
Example 03:
Create a list of ingredients for your Pizza:
- Title of your Pizza
- List of ingredients:
- Name
- Quantity
- Total time
-->