lesson 22: add a function parameter
This commit is contained in:
parent
0ba28e968e
commit
bca711b5d5
|
@ -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;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Reference in New Issue