add an input field
This commit is contained in:
parent
bee75dd9fa
commit
c9f6b1af57
|
@ -2,9 +2,13 @@ const app = Vue.createApp({
|
|||
data() {
|
||||
return {
|
||||
counter: 0,
|
||||
name: "",
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
setName(event) {
|
||||
this.name = event.target.value;
|
||||
},
|
||||
increaseCounter(inputNumber) {
|
||||
this.counter = this.counter + inputNumber;
|
||||
},
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
<button v-on:click="increaseCounter(10)">Add 10</button>
|
||||
<button v-on:click="decreaseCounter(5)">Reduce 5</button>
|
||||
<p>Result: {{ counter }}</p>
|
||||
<input type="text" v-on:input="setName">
|
||||
<p>Your Name: {{name}}</p>
|
||||
</section>
|
||||
</body>
|
||||
|
||||
|
|
Reference in New Issue