Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
| en:modul:m291:learningunits:lu07:theorie:01 [2025/04/28 08:55] – angelegt vdemir | en:modul:m291:learningunits:lu07:theorie:01 [2025/05/05 13:53] (aktuell) – vdemir | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| - | ====== | + | ====== |
| ===== Learning ojectives ===== | ===== Learning ojectives ===== | ||
| - | - Be able to explain the objectives of event handling and give examples. | + | - Be able to call existing methods (subroutines) in Vue. |
| - | - Be able to name actions that can follow events. | + | - Be able to programme your own methods in Vue. |
| - | - Be able to use simple | + | |
| ===== Introduction ===== | ===== Introduction ===== | ||
| - | After discussing | + | Actions such as clicking a mouse button can trigger simple actions such as changing colour, but also complex operations, e.g. calculation |
| + | |||
| + | ===== Introduction to Vue Methods ===== | ||
| + | In Vue.js, methods are functions defined inside a component’s methods object. These functions can be used to handle user events, perform calculations, | ||
| + | |||
| + | Vue methods are powerful tools for adding interactivity and logic to your components. By keeping behavior organized | ||
| + | |||
| + | ===== Example 1: Simple Counter ===== | ||
| + | This example shows how to use a Vue method to increment a counter when a button is clicked. The increment method is called when the button is clicked. It increases the count value by 1 using this.count++. | ||
| + | |||
| + | < | ||
| + | < | ||
| + | < | ||
| + | <button @click=" | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | export default { | ||
| + | data() { | ||
| + | return { | ||
| + | count: 0 | ||
| + | }; | ||
| + | }, | ||
| + | methods: { | ||
| + | increment() { | ||
| + | this.count++; | ||
| + | } | ||
| + | } | ||
| + | }; | ||
| + | </ | ||
| + | |||
| + | ===== Example 2: Greeting | ||
| + | This example uses a method to generate a greeting based on the user's name. The greet method creates a greeting using the current value of name and displays it with alert(). | ||
| + | |||
| + | < | ||
| + | < | ||
| + | <input v-model=" | ||
| + | <button @click=" | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | export default { | ||
| + | data() { | ||
| + | return { | ||
| + | name: '' | ||
| + | }; | ||
| + | }, | ||
| + | methods: { | ||
| + | greet() { | ||
| + | alert(`Hello, | ||
| + | } | ||
| + | } | ||
| + | }; | ||
| + | </ | ||
| + | |||
| + | |||
| - | ===== ... ===== | ||
| - | |||
| ===== Source ===== | ===== Source ===== | ||
| - | * [[https:// | + | [[https:// |
| + | |||
| ===== Vocabulary ===== | ===== Vocabulary ===== | ||
| ^ English ^ German ^ | ^ English ^ German ^ | ||
| - | | ... | ... | | + | | VAT | Mehrwertsteuer | |
| + | | to invoke | aufrufen | | ||
| + | | submission | Versendung, Einreichung | ||
| ---- | ---- | ||
| [[https:// | [[https:// | ||