lesson 22: add a function parameter

This commit is contained in:
Andreas Zweili 2021-01-18 17:58:29 +01:00
parent 0ba28e968e
commit bca711b5d5
2 changed files with 6 additions and 6 deletions

View File

@ -5,11 +5,11 @@ const app = Vue.createApp({
}; };
}, },
methods: { methods: {
increaseCounter() { increaseCounter(inputNumber) {
this.counter++; this.counter = this.counter + inputNumber;
}, },
decreaseCounter() { decreaseCounter(inputNumber) {
this.counter--; this.counter = this.counter - inputNumber;
}, },
}, },
}); });

View File

@ -17,8 +17,8 @@
</header> </header>
<section id="events"> <section id="events">
<h2>Events in Action</h2> <h2>Events in Action</h2>
<button v-on:click="increaseCounter">Add</button> <button v-on:click="increaseCounter(5)">Add</button>
<button v-on:click="decreaseCounter">Reduce</button> <button v-on:click="decreaseCounter(5)">Reduce</button>
<p>Result: {{ counter }}</p> <p>Result: {{ counter }}</p>
</section> </section>
</body> </body>