<div id="app" class="app">
<textarea v-model="log"></textarea>
<input @keyup.enter="add" type="text" v-model="input">
<button @click="log=''">Clear Log</button>
</div>
html, body {
display: grid;
justify-content: center;
align-content: center;
height: 100%;
font-family: sans-serif;
font-size: 1.1rem;
}
.app {
display: grid;
}
textarea {
padding: 5px;
border: 1px solid #ccc;
height: 150px;
margin-bottom: 5px;
}
input {
padding: 5px;
border: 1px solid #ccc;
margin-bottom: 5px;
}
const app = Vue.createApp({
data: function () {
return {
log: '',
input: ''
}
},
mounted: function () {
const log = localStorage.getItem('log')
if (log) {
console.log(log)
this.log = log
}
},
methods: {
add: function () {
this.log += "\n" + this.input
this.input = ''
}
},
watch: {
log: function () {
localStorage.setItem('log', this.log)
}
}
})
const vm = app.mount('#app')
This Pen doesn't use any external CSS resources.