Conditionally rendering
Use v-if, v-else-if, v-else (test by change property in console)
No beers were returned
1 beer was returned
{{beers}} beers were returned
Conditionally renders the element
Use v-show (test by change property in console)
No beers were returned
{{beers}}
Always renders the element (toggles CSS display properties)
Render List of items
- Index 0: {{beers[0]}}
- Index 1: {{beers[1]}}
loop over "item_i in list":
or loop over "item_i of list" (more consistent with JavaScript syntax):
Note that the loop starts at 1 (?? I dont' get it... See below...)
Traversing object properties
Looping through all property values in "currentUser"
To get each property name and property value:
- Property name is: {{k}}, Propery value is: {{v}}
To get each index as well
I.e use value, key, index
looping over a range - the alias starts at 1
properties - the alias starts at 0
Iterating through arrays
-
page.number is: {{page.number}}
Or, to get index:
-
page.number is: {{page.number}} and its index is: {{i}}
-
Beer at index {{i}} is: {{beer}}
Iterating through nested arrays
Page: {{page.number}}
Page {{page.number}}, section {{sec}}
Using v-for and v-if together (for has precedence)
{{maxAbv}}%
Detecting array changes
List to apply changes on:
Fast detta blir ju fel ordning?!
Note that Vue cannot update individual Array elements