Skip to content

Commit

Permalink
v-for
Browse files Browse the repository at this point in the history
  • Loading branch information
Murat2810 committed Oct 1, 2022
1 parent 35e9337 commit 269b1a7
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 7 deletions.
48 changes: 46 additions & 2 deletions SoloUebungen/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
<br />
We wish you a pleasant day.
</p>

// v-bind per element method
<hr>
<!-- v-bind per element method -->
<img v-bind="imgAttrs">
<br><br><br>
<p>Image Grâße wird in Vue definiert</p>
Expand All @@ -32,6 +32,50 @@
:src= "`https://picsum.photos/${width}/${height}`"
alt="Something random from picsum">

<!-- v-for mit Basic Array -->
<hr>
<h1>v-for mit Basic Array</h1>
<h2>Fruits in the Basket </h1>
<ul>
<li v-for="fruit in fruits" :key="fruit">{{fruit}}</li>
</ul>

<!-- v-for mit Basic Array mit index -->
<hr>
<h1>v-for mit Basic Array mit index</h1>
<h2>Fruits in the Basket </h1>
<ul>
<li v-for="(fruit, index) in fruits" :key="fruit">
{{index}} - {{fruit}}</li>
</ul>


<!-- v-for mit object literal -->
<h1>v-for mit object literal</h1>
<h2>Fruits in the Basket Emojis</h1>
<ul>
<li v-for="(emoji, name) in fruitsObjects" :key="name"> {{emoji}} - <strong>{{name}}</strong></li>
</ul>
<hr>

<!-- v-for mit json Γ€hnlichen Daten-->
<h1>v-for mit json Γ€hnlichen Daten</h1>
<h2>Fruits in the Basket Json</h1>
<ul>
<li v-for="(fruit, index) in fruitsJson" :key="fruit.id">
{{index}}-{{fruit.emoji}} - <strong>{{fruit.name}}</strong>-
</li>
</ul>

<!-- v-for mit json Γ€hnlichen Daten mit index-->
<h1>v-for mit json Γ€hnlichen Daten mit index</h1>
<h2>Fruits in the Basket Json</h1>
<ul>
<li v-for="(fruit, index) in fruitsJson" :key="fruit.id">
{{index}}-{{fruit.emoji}} - <strong>{{fruit.name}}</strong>-
</li>
</ul>

</div>

<script src="https://unpkg.com/vue@next"></script>
Expand Down
53 changes: 52 additions & 1 deletion SoloUebungen/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,65 @@ const app = Vue.createApp({
"Dieser Text ist mit vue.js kompiliert! Attribut v-text",
width: 400,
height: 400,

// v-bind per element method
imgAttrs: {
class: "red",
src: "https://picsum.photos/200/300",
alt: "Hard to describe",
title: "Something random from picsum",
},

// v-for mit Basic Array
fruits: [
"Apple",
"Banana",
"Melon",
"Blueberry",
"Strawberry",
"Ananas",
"Mango",
],


// v-for mit object literal
fruitsObjects: {
Apple: "🍎",
Banana: "🍌",
Melon: "πŸ‰",
Strawberry: "πŸ“",
Ananas: "🍍",
},

// v-for mit json Γ€hnlichen Daten
fruitsJson: [
{
id: 41,
name: "Apple",
emoji: "🍎",
},
{
id: 22,
name: "Melon",
emoji: "πŸ‰",
},
{
id: 32,
name: "Banana",
emoji: "🍌",
},
{
id: 92,
name: "Strawberry",
emoji: "πŸ“",
},
{
id: 52,
name: "Ananas",
emoji: "🍍",
},
],

};
},
directives: {
Expand Down
7 changes: 3 additions & 4 deletions attribute-binding/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</header>
<main>
<div id="app" class="inside">
<h1>{{ headline }}</h1>
<h1 :id="headline.replace(/\s/g, '-').toLowerCase()">{{ headline }}</h1>
<p>
Directives are special attributes with the <code>v-</code> prefix.
Directive attribute values are expected to be
Expand All @@ -35,11 +35,10 @@ <h1>{{ headline }}</h1>
DOM when the value of its expression changes. Let's review the example
we saw in the introduction:
</p>
<img :="imageAttrs">
<img :="imageAttrs" />
</div>

</main>
<script src="https://unpkg.com/vue@next"></script>
<script src="scripts.js"></script>
</body>
</html>
</html>

0 comments on commit 269b1a7

Please sign in to comment.