lesson 40: v-if
This commit is contained in:
parent
ccc8800093
commit
8bba59fa81
|
@ -1,7 +1,15 @@
|
||||||
const app = Vue.createApp({
|
const app = Vue.createApp({
|
||||||
data() {
|
data() {
|
||||||
return { goals: [] };
|
return {
|
||||||
},
|
goals: [],
|
||||||
|
enteredGoalValue: "",
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
addGoal() {
|
||||||
|
this.goals.push(this.enteredGoalValue);
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
app.mount('#user-goals');
|
app.mount("#user-goals");
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
<!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>Vue Course Goals</h1>
|
<h1>Vue Course Goals</h1>
|
||||||
</header>
|
</header>
|
||||||
<section id="user-goals">
|
<section id="user-goals">
|
||||||
<h2>My course goals</h2>
|
<h2>My course goals</h2>
|
||||||
<input type="text" />
|
<input type="text" v-model="enteredGoalValue" />
|
||||||
<button>Add Goal</button>
|
<button @click="addGoal">Add Goal</button>
|
||||||
<p>No goals have been added yet - please start adding some!</p>
|
<p v-if="goals.length === 0">No goals have been added yet - please start adding some!</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Goal</li>
|
<li>Goal</li>
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
Reference in New Issue