Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
en:modul:m291:learningunits:lu07:start [2025/04/29 12:26] – vdemir | en:modul:m291:learningunits:lu07:start [2025/05/05 13:28] (aktuell) – vdemir | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | ====== | + | ====== |
- | ===== Learning ojectives | + | ===== Theory |
- | - I can explain what //events// basically are. | + | |
- | - I can name at least three events-types | + | |
- | - I can apply events within the VUE framework | + | |
+ | <nspages .:theorie -h1 -exclude: | ||
- | ===== Introduction | + | ===== Assignments |
- | Events are actions or occurrences that happen in the browser—like a user | + | |
- | * clicking a button, | + | |
- | * typing into a field, or | + | |
- | * moving the mouse. | + | |
- | + | ||
- | In Vue, events let you respond to these actions by running specific methods when they occur. You can listen for events using the v-on directive or its shorthand @. This is how Vue apps become interactive, | + | |
- | In Vue.js, events are how we listen to user interactions and respond to them—things like clicks, keypresses, mouse movements, and more. Vue uses the v-on directive (or the shorthand @) to attach event listeners to HTML elements. | + | < |
- | When an event is triggered, Vue runs the method you specify. This makes your components interactive and dynamic. | + | ===== Solutions ===== |
- | ===== Source ===== | + | <nspages .:loesungen |
- | * [[https:// | + | |
- | + | ||
- | + | ||
- | ===== Example 1 ===== | + | |
- | This example below shows how to use v-on:click to handle a button click. | + | |
- | + | ||
- | * @click=" | + | |
- | * When the button is clicked, the sayHello method is called and the message displayed on the screen. | + | |
- | + | ||
- | < | + | |
- | < | + | |
- | <button @click=" | + | |
- | </ | + | |
- | </ | + | |
- | < | + | |
- | export default { | + | |
- | methods: { | + | |
- | sayHello() { | + | |
- | alert(' | + | |
- | } | + | |
- | } | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | ===== Example 2 ===== | + | |
- | Here's how you can capture input from a user and update data in real-time: | + | |
- | + | ||
- | * @input="updateName" | + | |
- | * The updateName method grabs the input value and updates the name data. | + | |
- | * The UI updates reactively with { { name } }. | + | |
- | + | ||
- | + | ||
- | < | + | |
- | < | + | |
- | <input @input=" | + | |
- | < | + | |
- | </ | + | |
- | </ | + | |
- | < | + | |
- | export default { | + | |
- | data() { | + | |
- | return { | + | |
- | name: '' | + | |
- | }; | + | |
- | }, | + | |
- | methods: { | + | |
- | updateName(event) { | + | |
- | this.name = event.target.value; | + | |
- | } | + | |
- | } | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | ===== Vocabulary ===== | + | |
- | ^ English ^ German ^ | + | |
- | | ... | ... | | + | |
---- | ---- | ||
[[https:// | [[https:// | ||