lesson 24: add keyup event
This commit is contained in:
parent
e1524b4661
commit
953fd0fb9e
|
@ -3,9 +3,13 @@ const app = Vue.createApp({
|
||||||
return {
|
return {
|
||||||
counter: 0,
|
counter: 0,
|
||||||
name: "",
|
name: "",
|
||||||
|
confirmedName: "",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
confirmName() {
|
||||||
|
this.confirmedName = this.name;
|
||||||
|
},
|
||||||
submitForm() {
|
submitForm() {
|
||||||
alert("Submitted");
|
alert("Submitted");
|
||||||
},
|
},
|
||||||
|
|
|
@ -20,8 +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($event, 'SomeOtherINput')">
|
<input type="text" v-on:input="setName($event, 'SomeOtherINput')" v-on:keyup.enter="confirmName" />
|
||||||
<p>Your Name: {{name}}</p>
|
<p>Your Name: {{ confirmedName }}</p>
|
||||||
<form v-on:submit.prevent="submitForm"><input type="text"><button>Sign Up</button></form>
|
<form v-on:submit.prevent="submitForm"><input type="text"><button>Sign Up</button></form>
|
||||||
</section>
|
</section>
|
||||||
</body>
|
</body>
|
||||||
|
|
Reference in New Issue