add example Vue app

This commit is contained in:
Andreas Zweili 2021-01-13 21:49:34 +01:00
parent bb90cae3ad
commit 4cff30d345
2 changed files with 21 additions and 3 deletions

View File

@ -1,5 +1,22 @@
"use strict";
Vue.createApp({
data() {
return {
goals: [],
enteredValue: "",
};
},
methods: {
addGoal() {
if (this.enteredValue !== "") {
this.goals.push(this.enteredValue);
}
this.enteredValue = "";
},
},
}).mount("#app");
// const buttonEl = document.querySelector("button");
// const inputEl = document.querySelector("input");
// const listEl = document.querySelector("ul");

View File

@ -12,13 +12,14 @@
<div id="app">
<div>
<label for="goal">Goal</label>
<input type="text" id="goal" />
<button>Add Goal</button>
<input type="text" id="goal" v-model="enteredValue" />
<button v-on:click="addGoal">Add Goal</button>
</div>
<ul>
<li>Test</li>
<li v-for="goal in goals">{{ goal }}</li>
</ul>
</div>
<script src="https://unpkg.com/vue@next"></script>
<script src="app.js"></script>
</body>