Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
| en:modul:m291:learningunits:lu08:theorie:01 [2025/04/10 10:01] – angelegt vdemir | en:modul:m291:learningunits:lu08:theorie:01 [2025/04/29 12:28] (aktuell) – gelöscht vdemir | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| - | ====== LU05a - VUE Events ====== | ||
| - | |||
| - | ===== Learning ojectives ===== | ||
| - | - I can explain what //events// basically are. | ||
| - | - I can name at least three events-types | ||
| - | - I can apply events within the VUE framework | ||
| - | |||
| - | |||
| - | ===== Introduction ===== | ||
| - | 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. | ||
| - | |||
| - | ===== Source ===== | ||
| - | * [[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. | ||
| - | |||
| - | < | ||
| - | <div> | ||
| - | <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=" | ||
| - | * The updateName method grabs the input value and updates the name data. | ||
| - | * The UI updates reactively with { { name } }. | ||
| - | |||
| - | |||
| - | < | ||
| - | <div> | ||
| - | <input @input=" | ||
| - | < | ||
| - | </ | ||
| - | </ | ||
| - | < | ||
| - | export default { | ||
| - | data() { | ||
| - | return { | ||
| - | name: '' | ||
| - | }; | ||
| - | }, | ||
| - | methods: { | ||
| - | updateName(event) { | ||
| - | this.name = event.target.value; | ||
| - | } | ||
| - | } | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | |||
| - | |||
| - | |||
| - | ===== Vocabulary ===== | ||
| - | ^ English ^ German ^ | ||
| - | | ... | ... | | ||
| - | |||
| - | ---- | ||
| - | [[https:// | ||