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