-
Notifications
You must be signed in to change notification settings - Fork 0
/
07list.html
55 lines (52 loc) · 1.43 KB
/
07list.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>07 List</title>
<script src="src/vue.js"></script>
</head>
<body>
<div id="app">
<!-- SIMPLE ARRAY -->
<ul>
<li v-for="ingredient in ingredients">{{ingredient}}</li>
</ul>
<ul>
<!-- Para que quede bien almacenada sin darme errores por ser dinámico, es más seguro (ojo la i sería dinámica).
<li v-for="(ingredient, i) in ingredients" :key="ingredient">{{ingredient}} ({{i}})</li> -->
<li v-for="(ingredient, i) in ingredients">{{ingredient}} ({{i}})</li>
</ul>
<template v-for="(ingredient, index) in ingredients">
<h1>{{ingredient}}</h1>
<p>{{index}}</p>
</template>
<!-- COMPLEX OBJECT -->
<!-- directly -->
<ul>
<li v-for="person in persons">{{person.name}}</li>
</ul>
<ul>
<li v-for="person in persons">
<span v-for="value in person">{{value}} </span>
</li>
</ul>
<!-- with key -->
<ul>
<li v-for="person in persons">
<div v-for="(value, key) in person">{{key}}: {{value}} </div>
</li>
</ul>
<!-- with key and index -->
<ul>
<li v-for="person in persons">
<div v-for="(value, key, index) in person">{{key}}: {{value}} ({{index}}) </div>
</li>
</ul>
<!-- -->
<button @click = "ingredients.push('spices')">Add new</button>
</div>
</body>
<footer>
<script src="07list.js"></script>
</footer>
</html>