lesson 22: add a function parameter
This commit is contained in:
parent
0ba28e968e
commit
bca711b5d5
|
@ -5,11 +5,11 @@ const app = Vue.createApp({
|
|||
};
|
||||
},
|
||||
methods: {
|
||||
increaseCounter() {
|
||||
this.counter++;
|
||||
increaseCounter(inputNumber) {
|
||||
this.counter = this.counter + inputNumber;
|
||||
},
|
||||
decreaseCounter() {
|
||||
this.counter--;
|
||||
decreaseCounter(inputNumber) {
|
||||
this.counter = this.counter - inputNumber;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
</header>
|
||||
<section id="events">
|
||||
<h2>Events in Action</h2>
|
||||
<button v-on:click="increaseCounter">Add</button>
|
||||
<button v-on:click="decreaseCounter">Reduce</button>
|
||||
<button v-on:click="increaseCounter(5)">Add</button>
|
||||
<button v-on:click="decreaseCounter(5)">Reduce</button>
|
||||
<p>Result: {{ counter }}</p>
|
||||
</section>
|
||||
</body>
|
||||
|
|
Reference in New Issue