add my solution for the second assignment
This commit is contained in:
parent
886c91c6d3
commit
843bea6d06
|
@ -0,0 +1,23 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const app = Vue.createApp({
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
firstInputValue: "",
|
||||||
|
secondInputValue: "",
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
showAlert() {
|
||||||
|
alert("Some alert");
|
||||||
|
},
|
||||||
|
updateFirstOutput(event) {
|
||||||
|
this.firstInputValue = event.target.value;
|
||||||
|
},
|
||||||
|
updateSecondOutput(event) {
|
||||||
|
this.secondInputValue = event.target.value;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
app.mount("#assignment");
|
|
@ -1,17 +1,16 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Vue Basics</title>
|
<title>Vue Basics</title>
|
||||||
<link
|
<link href="https://fonts.googleapis.com/css2?family=Jost:wght@400;700&display=swap" rel="stylesheet" />
|
||||||
href="https://fonts.googleapis.com/css2?family=Jost:wght@400;700&display=swap"
|
|
||||||
rel="stylesheet"
|
|
||||||
/>
|
|
||||||
<link rel="stylesheet" href="styles.css" />
|
<link rel="stylesheet" href="styles.css" />
|
||||||
<script src="https://unpkg.com/vue@next" defer></script>
|
<script src="https://unpkg.com/vue@next" defer></script>
|
||||||
<script src="app.js" defer></script>
|
<script src="app.js" defer></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<h1>Events</h1>
|
<h1>Events</h1>
|
||||||
|
@ -19,15 +18,16 @@
|
||||||
<section id="assignment">
|
<section id="assignment">
|
||||||
<h2>Event Practice</h2>
|
<h2>Event Practice</h2>
|
||||||
<!-- 1) Show an alert (any text of your choice) when the button is pressed -->
|
<!-- 1) Show an alert (any text of your choice) when the button is pressed -->
|
||||||
<button>Show Alert</button>
|
<button v-on:click="showAlert">Show Alert</button>
|
||||||
<hr />
|
<hr />
|
||||||
<!-- 2) Register the user input on "keydown" and output it in the paragraph (hint: event.target.value helps) -->
|
<!-- 2) Register the user input on "keydown" and output it in the paragraph (hint: event.target.value helps) -->
|
||||||
<input type="text" />
|
<input type="text" v-on:keydown="updateFirstOutput" />
|
||||||
<p>OUTPUT</p>
|
<p>{{ firstInputValue }}</p>
|
||||||
<hr />
|
<hr />
|
||||||
<!-- 3) Repeat 2) but only output the entered value if the ENTER key was pressed -->
|
<!-- 3) Repeat 2) but only output the entered value if the ENTER key was pressed -->
|
||||||
<input type="text" />
|
<input type="text" v-on:keydown.enter="updateSecondOutput" />
|
||||||
<p>OUTPUT</p>
|
<p>{{ secondInputValue }}</p>
|
||||||
</section>
|
</section>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
Reference in New Issue
Block a user