Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
en:modul:m291:learningunits:lu05:theorie:03 [2025/01/23 12:52] – angelegt vdemir | en:modul:m291:learningunits:lu05:theorie:03 [2025/03/14 12:36] (aktuell) – vdemir | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | ====== LU05c - v-bind practical application in Webstorm - TBD ====== | + | ====== LU05c - v-if ====== |
===== Learning ojectives ===== | ===== Learning ojectives ===== | ||
- | - Be able to apply the v-bind directives | + | - I can explain what the directive |
- | - Using the SFC concept | + | - I can name the three v-if variants that are possible |
- | - | + | - I can apply v-if to specific examples. |
+ | |||
+ | ===== Sources ===== | ||
+ | * [[https:// | ||
+ | | ||
+ | |||
===== Introduction ==== | ===== Introduction ==== | ||
- | After practising our new vue powers | + | The v-if directive in Vue.js is used to conditionally render elements |
- | This task is both more challanging and more enganging at the same time, since it requires additional skill as we have not only to programm vue code but also to handle server starts and stops, ports and browser-calls as well. But first things first. | + | <div id=" |
+ | <button @click=" | ||
+ | <p v-if=" | ||
+ | </ | ||
+ | < | ||
+ | new Vue({ | ||
+ | el: '# | ||
+ | data: { | ||
+ | isVisible: true | ||
+ | }, | ||
+ | methods: { | ||
+ | toggleMessage() { this.isVisible = !this.isVisible; | ||
+ | } | ||
+ | } | ||
+ | }); | ||
+ | </ | ||
- | In this chapter we are going to start with our "Hello World" to Webstorm. I hope you are ready!!! | + | In this example above, the paragraph element (<p>) is conditionally displayed based on the value of the // |
- | ===== TDB ===== | + | ===== Variants |
+ | There are basically three variants of //v-if//: | ||
+ | - v-if | ||
+ | - v-else-if | ||
+ | - v-else | ||
+ | ==== 1. v-if ==== | ||
+ | * Used to conditionally render an element based on whether the condition evaluates to //true//. | ||
+ | * If the condition is //false//, the element is completely removed from the DOM. | ||
+ | **Example: | ||
+ | | ||
+ | <p v-if=" | ||
+ | | ||
+ | ==== 2. v-else-if ==== | ||
+ | * Used to create an additional condition in conjunction with //v-if//. | ||
+ | * orks like an //else-if// statement in programming, | ||
+ | |||
+ | <p v-if=" | ||
+ | <p v-else-if=" | ||
+ | |||
+ | ==== 3. v-else ==== | ||
+ | * Provides a fallback for when none of the //v-if// or // | ||
+ | * It does not accept any condition and must directly follow //v-if// or // | ||
+ | |||
+ | <p v-if=" | ||
+ | <p v-else-if=" | ||
+ | <p v-else> | ||
+ | |||
+ | ===== Additional Material ===== | ||
+ | |||
+ | {{: | ||
===== Vocabulary ===== | ===== Vocabulary ===== | ||
+ | |||
^ English ^ German ^ | ^ English ^ German ^ | ||
- | | ...| ... | | + | | to render |
+ | | conjunction | verbindung | ||
---- | ---- | ||
[[https:// | [[https:// | ||