//pure js
/*const buttonEl = document.querySelector('button');
const inputEl = document.querySelector('input');
const ulEl = document.querySelector('ul');
buttonEl.addEventListener('click', function(){
const inputValue = inputEl.value;
const listItem = document.createElement('li');
if (inputValue != ''){
listItem.textContent = inputValue;
ulEl.appendChild(listItem);
inputEl.value = '';
}
});*/
Vue.createApp({
data(){
return{
goals: [],
enteredValue: ''
};
},
methods: {
addGoal() {
this.goals.push(this.enteredValue);
this.enteredValue = '';
}
}
}).mount('#app');
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>A First App</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<div id="app">
<div>
<label for="goal">Goal</label>
<input type="text" id="goal" v-model="enteredValue"/>
<button v-on:click="addGoal">Add Goal</button>
</div>
<ul>
<li v-for="goal in goals">{{goal}}</li>
</ul>
</div>
<script src="https://unpkg.com/vue@next"></script>
<script src="app.js"></script>
</body>
</html>